Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2012
1,265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(function() {
  2.     var Images = $("#sky div"), Timers = [];
  3.  
  4.     var makeFly = function (Id, Range, Duration, Direction) {
  5.         return function () {
  6.             var Way1 = {}, Way2 = {};
  7.             Way1[Direction] = '+=' + Range;
  8.             Way2[Direction] = '-=' + Range;
  9.             $('#'+Id).animate(Way1,Duration).animate(Way2,Duration);
  10.         };
  11.     };
  12.    
  13.     Images.each(function() {
  14.         var Image = $(this),
  15.             Id = Image.attr('id'),
  16.             Range = Image.attr('data-fly-range'),
  17.             Duration = parseInt(Image.attr('data-fly-duration')),
  18.             Direction = Image.attr('data-fly-direction');
  19.  
  20.         var fly = makeFly(Id, Range, Duration, Direction);
  21.  
  22.         Timers[Id] = setInterval(fly, Duration*2);
  23.         fly();
  24.     });
  25. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement