I’m animating a scrolling div, and have been able to get the trigger to fire, scroll, and stop on click and /or mouseenter. Now I’d like to have it pause when the mouse hovers over the div instead of stop. I’m a total jquery newb, so I really don’t know what will work and what won’t. Here’s my code so far, and it’s working fine.
$(document).ready(function() {
var sL = 4000;
$('.scrolls').animate({
scrollLeft : sL
},100000, 'linear');
$(".scrolls").on("click",function(){
$(this).stop(true,false);
});
})
Any help is SO VERY appreciated!!
Thanks!
This should work:
With this code, when you hover over the div, the animations stops. We record how much time has passed since it started, so we can create a new animation that will simulate the resuming of the old one, by setting its duration to our original duration less the time already passed.
Hope this helps.
Why not using mouseenter and mouseleave events..
Please check this fiddle out:
Modified Code
Basically you will be doing something like this:
Please have a look at this fiddle http://jsfiddle.net/93Ta8/
All I am doing is making use of
and