Skip to content

Instantly share code, notes, and snippets.

@jasonknebel
Created February 26, 2013 04:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonknebel/5035908 to your computer and use it in GitHub Desktop.
Save jasonknebel/5035908 to your computer and use it in GitHub Desktop.
Bouncing ball!
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