欢迎来到天天文库
浏览记录
ID:38068714
大小:29.00 KB
页数:3页
时间:2019-05-25
《简单的网页鼠标跟随代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、放入
2、ff;font-size:0;overflow:hidden;width:2px;height:2px;}varFollow=function(){var$=function(i){returndocument.getElementById(i)},addEvent=function(o,e,f){o.addEventListener?o.addEventListener(e,f,false):o.attachEvent('on'+
3、e,function(){f.call(o)})},OBJ=[],sp,rs,N=0,m;varinit=function(id,config){this.config=config
4、
5、{};this.obj=$(id);sp=this.config.speed
6、
7、4;rs=this.config.animR
8、
9、1;m={x:$(id).offsetWidth*.5,y:$(id).offsetHeight*.5};this.setXY();this.start();}init.prototype={set
10、XY:function(){var_this=this;addEvent(this.obj,'mousemove',function(e){e=e
11、
12、window.event;m.x=e.clientX;m.y=e.clientY;})},start:function(){vark=180/Math.PI,OO,o,_this=this,fn=this.config.fn;OBJ[N++]=OO=newCObj(null,0,0);for(vari=0;i<360;i+=20){varO=OO;for(va
13、rj=10;j<35;j+=1){varx=fn(i,j).x,y=fn(i,j).y;OBJ[N++]=o=newCObj(O,x,y);O=o;}}setInterval(function(){for(vari=0;i14、css.left="-1000px";this.css.zIndex=1000-N;document.getElementById("screen").appendChild(obj);this.ddx=0;this.ddy=0;this.PX=0;this.PY=0;this.x=0;this.y=0;this.x0=0;this.y0=0;this.cx=cx;this.cy=cy;this.parent=p;}CObj.prototype.run=function(){if(!this.parent)15、{this.x0=m.x;this.y0=m.y;}else{this.x0=this.parent.x;this.y0=this.parent.y;}this.x=this.PX+=(this.ddx+=((this.x0-this.PX-this.ddx)+this.cx)/rs)/sp;this.y=this.PY+=(this.ddy+=((this.y0-this.PY-this.ddy)+this.cy)/rs)/sp;this.css.left=Math.round(this.x)+'px';16、this.css.top=Math.round(this.y)+'px';}returninit;}();
14、css.left="-1000px";this.css.zIndex=1000-N;document.getElementById("screen").appendChild(obj);this.ddx=0;this.ddy=0;this.PX=0;this.PY=0;this.x=0;this.y=0;this.x0=0;this.y0=0;this.cx=cx;this.cy=cy;this.parent=p;}CObj.prototype.run=function(){if(!this.parent)
15、{this.x0=m.x;this.y0=m.y;}else{this.x0=this.parent.x;this.y0=this.parent.y;}this.x=this.PX+=(this.ddx+=((this.x0-this.PX-this.ddx)+this.cx)/rs)/sp;this.y=this.PY+=(this.ddy+=((this.y0-this.PY-this.ddy)+this.cy)/rs)/sp;this.css.left=Math.round(this.x)+'px';
16、this.css.top=Math.round(this.y)+'px';}returninit;}();
此文档下载收益归作者所有