admin管理员组

文章数量:1426072

I'm using jQuery jCarousel for a slider, after few mins I found the way to stop the slider on mouseover, but the problem is it doesn't stop immediately on mouseover, it only stop at the end of the image set (3 images in my demo). However it does start immediately on mouse out. I'm new javascript stuff and couldn't do much by diving to it's source. :(

My Current Code -

Thank You

I'm using jQuery jCarousel for a slider, after few mins I found the way to stop the slider on mouseover, but the problem is it doesn't stop immediately on mouseover, it only stop at the end of the image set (3 images in my demo). However it does start immediately on mouse out. I'm new javascript stuff and couldn't do much by diving to it's source. :(

My Current Code - http://bit.ly/ijNcow

Thank You

Share Improve this question asked Mar 20, 2011 at 12:05 Sahan H.Sahan H. 4727 silver badges14 bronze badges 1
  • This issue has been fixed. Please take a look: code.google./p/jcarausel-lite-pause-on-hover-fixed – saikatbiswas82 Commented May 23, 2012 at 15:24
Add a ment  | 

2 Answers 2

Reset to default 4

Often, we manage a jCarousel by using .click(). In this case - you can use the following code to stop the animation:

itemLoadCallback: {
    onBeforeAnimation: function(jc, state) {
        jc.lock();
    }
}  

The jc.lock() or jc.unlock() functions stop and resume the animation, respectively.

The jCarousel code uses two timers that I can see. The timer wrapped in jQuery's animation support and a timer that scrolls the underlying list forward by one item. Your page's code clears the second timer by calling carousel.stopAuto(), but not the animation timer. Hence the animation continues until the next item has been scrolled in (in essence, that the second item reaches the topmost position).

To clear that one you'll have to also call jQuery's stop() function on the carousel element. At a guess (no, I have not tested this), you should call

$('#listing').stop(true); 

Having said that, I'm not sure what will happen to the user experience if you've paused half way through an animation and then started it up again (by moving the mouse out, say). The animation won't start up where you left off, that's for sure. I would also guess that the carousel will assume that the animation pleted normally and you'll get a "jump effect" as it sets the top item properly in place.

本文标签: javascriptjCarousel stop immediately on mouseoverStack Overflow