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

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 0.67 KB  |  hits: 11  |  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. How to make animation easing (ease-in and ease-out) duration-independent?
  2. Short animation (X milliseconds)
  3. |<<<<|-------------------|>>>>|
  4.  10ms                     10ms
  5.  
  6. Long animation (2X milliseconds)
  7. |<<<<|-----------------------------------------|>>>>|
  8.  10ms                                           10ms
  9.        
  10. var $obj     = $('#some-id'),
  11.     ani_dist = 500;
  12.  
  13. //animate first easing
  14. $obj.stop().animate({ left : 100 }, 500, 'easeOutCirc', function () {
  15.  
  16.     //animate main body of the animation
  17.     $obj.animate({ left : (ani_dist - 100) }, 1000, 'linear', function () {
  18.  
  19.         //animate the last easing
  20.         $obj.animate({ left : ani_dist }, 500, 'easeInCirc');
  21.     });
  22. });