Created
February 26, 2013 04:33
-
-
Save jasonknebel/5035908 to your computer and use it in GitHub Desktop.
Bouncing ball!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var width = 450; | |
var height = 200; | |
var time = 750; | |
var up_right = function(){ | |
$('img').animate({marginTop: 0, marginLeft: (width - 31) / 2}, time, 'linear', down_right); | |
}; | |
var down_right = function(){ | |
$('img').animate({marginTop: height-30, marginLeft: width - 31}, time, 'linear', up_left); | |
}; | |
var up_left = function(){ | |
$('img').animate({marginTop: 0, marginLeft: (width - 31) / 2}, time, 'linear', down_left); | |
}; | |
var down_left = function(){ | |
$('img').animate({marginTop: height-30, marginLeft: 0}, time, 'linear', up_right); | |
}; | |
$(function() { | |
$('.box').css({height: height, width: width}); | |
$('img').css({marginTop: height-30}) | |
up_right(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment