I am trying to animate a background on mousemove with some weakening using jquery animate. But I canβt understand how to stop the sequence of animation and make the animation βfollowβ the mouse
HTML:
Animate Background<br /> <div id="animateme"></div>β
JS:
$("#animateme").bind('mousemove', function(e) { $(this).animate({ 'background-position-x': e.pageX, 'background-position-y': e.pageY }, 100, 'swing'); });β
I installed jsfiddle to hopefully show what I mean http://jsfiddle.net/KunZ4/1/
Hover over the top image and you will see how the background animation follows the mouse. But I want to add some relief to this, so it follows the mouse a little smoother.
Using jquery animations seems to be in the queue, but I want the animation to get the mouse a little delay when the mouse movement is stopped.
I want to achieve this without using a user interface or plugins.
Hope this makes some sense
source share