JS implementation of exquisite picture following mouse effect example

Source: Internet
Author: User

The example of this article describes the implementation of JS beautiful picture following mouse effect method. Share to everyone for your reference. The implementation methods are as follows:

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26-27--28 29---30 31--32 33 34 35 36 37 38-39 40 41 42 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 5 86 87 88 89 90 91 92 93 <html> <head> <meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/> <title> exquisite js mouse follow code </title> </head> <body> <script> a= document.getElementById B=document.all; C=document.layers; T1=new Array ("Trail1.gif", 38,35, "Trail2.gif", 30,31, "Trail3.gif", 28,26, "Trail4.gif", 22,21, "Trail5.gif", 16, 16, " Trail6.gif ", 10,10) var offsetx=15 var offsety=10 nos=parseint t1.length/3 (rate=50) ie5fix1=0; ie5fix2=0; Rightedge=b? DOCUMENT.BODY.CLIENTWIDTH-T1[1]: window.innerwidth-t1[1]-20 bottomedge=b? DOCUMENT.BODY.SCROLLTOP+DOCUMENT.BODY.CLIENTHEIGHT-T1[2]: window.pageyoffset+window.innerheight-t1[2] for (i=0;i <nos;i++) {CreateContainer ("CUR" +i,i*10,i*10,i*3+1,i*3+2, "" ", <img src= '" +t1[i*3]+ "' Width=" +T1[(i*3+1)]+ " Height= "+t1[(i*3+2)]+" border=0> ")} function CreateContainer (n,xp,yp,w,h,at,ht,op,st) {with (document) {Write (! A &&! B)? "<layer id= '" +n+ "' left=" +xp+ "top=" +yp+ "width=" +w+ "height=" +h: "<div id=" "+n+" ' "+" styLe= ' position:absolute;left: "+xp+"; Top: "+yp+"; Width: "+w+"; Height: "+h+"; "); if (St) {if (C) write ("style= '"); write (st+ "; ")} else write (A | | B)? "'": ""; Write (at)? At+ ">": ">"); Write (HT)? HT: ""); if (! Op) Closecontainer (N)}} function Closecontainer () {document.write (A | | B)? " </div> ': ' </layer> '} function Getxpos (n) {if (A) return parseint (document.getElementById (n). Style.left) else if (B) return parseint (b[n].style.left) Else return c[n].left} function Getypos (N) {if (A) return parseint (document. getElementById (n). Style.top) Else if (B) return parseint (b[n].style.top) Else return c[n].top} function Movecontainer (n, Dx,dy) {c= (A)? document.getElementById (N). Style: (B)? B[n].style: (C)? C[n]: ""; if (! B) {rightedge=window.innerwidth-t1[1]-20 bottomedge=window.pageyoffset+window.innerheight-t1[2]} c.left=Math.min ( Rightedge, DX+OFFSETX); C.top=math.min (Bottomedge, dy+offsety); function cycle () {//if (IE5) if (document.all&&window.print) {IE5Fix1=document.body.scrollleft; Ie5fix2=document.body.scrolltop; For (i=0;i< (nos-1); i++) {Movecontainer ("CUR" +i,getxpos ("CUR" + (i+1)), Getypos ("CUR" + (I+1))}} function Newpos (e) {Movecontainer ("CUR" + (nos-1), (b)? Event.clientx+ie5fix1:e.pagex+2, (b)? event.clienty+ie5fix2:e.pagey+2)} function Getedgesie () {rightedge=document.body.clientwidth-t1[1] bottomedge=document.body.scrollheight-t1[2]} if (B) { Window.onload=getedgesie Window.onresize=getedgesie} if (document.layers) document.captureevents (Event.MOUSEMOVE) Document.onmousemove=newpos setinterval ("cycle ()", rate) </script> </body> </html>

The

wants this article to help you with your JavaScript programming.

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.