QQ Space Mouse following Image code

Source: Internet
Author: User
Tip: you can modify some code before running

<script language="JavaScript">Var images='sony.jpg ';<!--图片的路径设置-->Var amount = 7;<!--图片显示的个数-->Var cnter = 70; var step; var currStep = 0; var Xpos = 0;<!--横坐标-->Var Ypos = 0;<!--纵坐标--><!--如果是ie浏览器-->{Document. write ('<div id="ieDiv" >')<!--显示-->Document. write ('<div id="c" >'); For (n = 0; n <amount; n ++)<!--依次显示每个图片-->Document. write ('') document. write ('</div>') Document. write ('</div>') Function MsieMouseFollow (evnt ){<!--图片跟随鼠标运动-->Xpos = document. body. scrollLeft + event. X-5;<!--获取横坐标-->Ypos = document. body. scrollTop + event. Y-5;<!--获取纵坐标-->} Document. onmousemove = MsieMouseFollow;<!--鼠标移动后调用msiemousefollow函数-> } function Swirl(){if (currStep<0.0550)<!--如果当前的步长小于某个值-->Step = 0.001;<!--赋值给step--><!--如果是ie浏览器-->{For (I = 0; I<ieDiv.all.c.all.length;i++)<!--依次处理每一个图片所在的层-->{IeDiv. all. c. all [I]. style. top = Ypos + cnter * Math. cos (currStep + I * 4.5)/5) * Math. sin (currStep) * 150 );<!--按照一定的规则计算出每一个图片所在层的显示的上边界,并显示-->IeDiv. all. c. all [I]. style. left = Xpos + cnter * Math. sin (currStep + I * 4.5)/5) * Math. sin (currStep) * 150 );<!--按照一定的规则计算出每一个图片所在层的显示的左边界,并显示-->} CurrStep + = step;<!--当前的步长增加-->SetTimeout ("Swirl ()", 10 );<!--设定调用swirl函数的时间间隔-->If (currsteps> 0.0540)<!--如果当前的步长大于某个值-->{Step + = 0.002;<!--调整step的值--> <!--如果是ie浏览器-->{For (I = 0; I<ieDiv.all.c.all.length;i++) {ieDiv.all.c.all[i].style.top=Ypos+cnter*Math.cos((currStep+i*4.5)/5)<!--按照一定的规则计算出每一个图片所在层的显示的上边界,并显示-->IeDiv. all. c. all [I]. style. left = Xpos + cnter * Math. sin (currStep + I * 4.5)/5)<!--按照一定的规则计算出每一个图片所在层的显示的上边界,并显示-->}}} If (step> 0.5)<!--判断当前的动画状态-->{Step = 0.5;<!--变量重新赋值-->Cnter-= 8;<!--变量重新赋值-->} <!--如果是ie浏览器-->_ Y =-document. body. clientWidth;<!--获得当前窗口的宽度-->If (cnter <= _ y) {currStep = 0;<!--重置变量-->Step = 0.001;<!--重置变量-->Cnter = 70;<!--重置变量-->} Swirl ();<!--直接调用swirl函数--></script><!--本例程实现了跟随鼠标旋转的图片的效果--><!--鼠标事件的捕捉以及处理过程--><!--设定动画中对象的轨迹--><!--对不同浏览器的分别处理--><!--动画效果的实现-->Keywords: QQ space, mouse, follow image
Tip: you can modify some code before running

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.