Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- animateM();
- });
- function newPosition(){
- var h = $(window).height() - 50;
- var w = $(window).width() - 50;
- var nh = Math.floor(Math.random() * h);
- var nw = Math.floor(Math.random() * w);
- return [nh,nw];
- }
- function animateM(){
- var newq = newPosition();
- $('.animateM').animate({ top: newq[0], left: newq[1] }, function(){
- animateM();
- });
- };
- setTimeout(function() {
- $('.animateM').animate({
- top: newq[0],
- left: newq[1],
- }, 750);
- , 2000 ); // 2000 is duration
Add Comment
Please, Sign In to add comment