Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 1.02 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. jQuery animate being shaky
  2. jQuery.fn.extend({
  3.     letsTravel: function() {
  4.         var horizontalRange = jQuery(this).width() - jQuery(this).parent().width();
  5.         var verticalRange = jQuery(this).height() - jQuery(this).parent().height();
  6.         var halfHeight = div(verticalRange,2);
  7.         //horizontalRange and verticalRange are maximum valid horizontal/vertical offset
  8.         //all coordinates should be below 0 because start point is 0,0
  9.         jQuery(this).animate({left: (horizontalRange-120)*(-1), top: halfHeight*(-1)},20000, 'linear', function(){
  10.             jQuery(this).animate({left: horizontalRange*(-1), top: verticalRange*(-1)},20000, 'linear', function(){
  11.                 jQuery(this).animate({left: (horizontalRange/2)*(-1)},10000, 'linear', function(){
  12.                     jQuery(this).animate({left: 0, top: halfHeight*(-1)},20000, 'linear', function(){
  13.                         jQuery(this).animate({top: 0},10000, 'linear');
  14.                     });
  15.                 });
  16.             });
  17.         });
  18.     }      
  19. });