JQ Handwriting Collision Ball

Source: Internet
Author: User

1JQuery.fn.bump =function() {2     varEle = $ ( This);3     varElew =ele.width ();4     varEleh =ele.height ();5     //height and width range of motion6     varW = $ (window). Width ()-Elew;7     varH = $ (window). Height ()-Eleh;8Window.onresize =function () {9W = $ (window). Width ()-Elew;TenH = $ (window). Height ()-Eleh; One     } A     varTan_b = H/W; -     varTan = Math.random (); -     varV_h = 500; the     varS_h = 0; -     vart = 0, -x = 0, -y = 0; +A = Math.floor (Math.random () *W); -b = Math.floor (Math.random () *H); +     //create an object in a direction A     varDer = { atLtrue, -T:false, -R:false, -B:true -     }; -     // First in Ele.css ({ -' Top ': B, to' Left ': A +     }); -     functionMove () { the         //1 *         if(!der.l &&!der.t && DER.R &&der.b) { $             if(a!=W) {Panax Notoginseng                 varTana = (h-b)/(W-a); -                 if(Tana <Math.Abs (TAN)) { they =H; +x = (y-b)/tan +A; ADer.l=false;d er.t=true;d er.r=true;d er.b=false; the}Else { +x =W; -y = (x-a) * tan +b; $Der.l=true;d er.t=false;d er.r=false;d er.b=true; $                 } -}Else { -X =A; they =b; -Der.l=true;d er.t=false;d er.r=false;d er.b=true;Wuyi             } the         //2 -}Else if(!der.l && der.t && DER.R &&!)der.b) { Wu             if(a!=v) { -                 varTana = b/(W-a); About                 if(Tana <Math.Abs (TAN)) { $y = 0; -x = B/tan +A; -Der.l=false;d er.t=false;d er.r=true;d er.b=true; -}Else { Ax =W; +y = B-(x-a) *Tan; theDer.l=true;d er.t=true;d er.r=false;d er.b=false; -                 } $}Else { theX =A; they =b; theDer.l=true;d er.t=true;d er.r=false;d er.b=false; the             }     -         //3 in}Else if(der.l && der.t &&!DER.R &&!)der.b) { the             if(a!=0){ the                 varTana = b/A; About                 if(Tana <Math.Abs (TAN)) { they = 0; thex = A-b/Tan; theDer.l=true;d er.t=false;d er.r=false;d er.b=true; +}Else { -x = 0; they = b-a*Tan;BayiDer.l=false;d er.t=true;d er.r=true;d er.b=false; the                 } the}Else { -x = 0; -y =b; theDer.l=false;d er.t=true;d er.r=true;d er.b=true; the             }     the         //4 the}Else if(der.l &&!der.t &&!DER.R &&der.b) { -             if(a!=0){ the                 varTana = (h-b)/A; the                 if(Tana <Math.Abs (TAN)) { they =H;94x = A-(h-b)/tan; theDer.l=true;d er.t=true;d er.r=false;d er.b=false; the}Else { thex = 0;98y = B + *Tan; AboutDer.l=false;d er.t=false;d er.r=true;d er.b=true; -                 }101}Else {102x = 0;103y =b;104Der.l=false;d er.t=false;d er.r=true;d er.b=true; the             }        106         }107S_h = Math.sqrt ((x-a) * (x-a) + (y-b) * (yb));108t = (s_h/v_h) *1000;109 ele.animate ({ the' Top ': Y,111' Left ': x the},t, ' linear ',function(){113A =x; theb =y; the move (); the         });117     }118 move ();119};

Calls and HTML

JQ Handwriting Collision Ball

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.