Search code examples
jqueryanimationsmoothing

jquery/javascript the best practice for smoothest animation on keydown/mousedown


What's the best way to do this,

  • with setTimeout() and css({left: '+=1'});

or

  • using the animation({left:+=30}, '300', 'linear');

As much as I think that setTimeout and css() is the right way, I can't seem to achieve the right smoothness with it, not to mention that is seems to eat memory alot..

Note that I'm not trying to animation on mousedown and stop on mouseup, not animation from one point to another on click.


Solution

  • animate() increases values by tenths, that's why it's smoother.

    Guess you could do the same with css(), but why reinvent the wheel.