Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var balloon = $('div.balloon'),
- x = 0,
- y = 0,
- dir = 1, // direction
- alt = 1 // altitude
- function animate_balloon(){
- // increment x axis
- x = x + (1 * dir);
- // increment y axis
- y = y + (1 * alt);
- balloon.css({
- 'margin-top' : y + 'px',
- 'margin-left' : x + 'px'
- });
- if(x == 10){
- dir = -1;
- } else if(x == 0){
- dir = 1;
- }
- if(y == 15){
- alt = -1;
- } else if(y == 0){
- alt = 1;
- }
- setTimeout(animate_balloon, 250);
- }
- animate_balloon();
Add Comment
Please, Sign In to add comment