cycle2 icon indicating copy to clipboard operation
cycle2 copied to clipboard

Pause-on-hover

Open fviscovo opened this issue 9 years ago • 1 comments

Hi Mike,

I am using a carousel slider with easing linear and pause-on-hover, its run :). I saw that slider have a delay for stop, its pause when the next slide will be started, but i wanna that pause of slider immediately. I tried search a solution in cycle2 website, stackoverflow and google but without success :(

Can you help me?

Congratulations for cycle plugin, its the best slider of jquery.

fviscovo avatar Mar 18 '16 17:03 fviscovo

The following worked for me:

First off, remove any setting for "data-cycle-pause-on-hover"... leave it as default. Then attach this hover event.

$('.cycle-slideshow').hover(
    function(){
        var curPos = $(this).find('.cycle-carousel-wrap').css('left');
        $(this).cycle('pause').cycle('stop');
        $(this).find('.cycle-carousel-wrap').css('left',curPos);
    },
    function(){
        $(this).cycle('resume');
    }
);

You may need to adjust this for your purposes.

I think this works because "pause" normally doesn't happen until the next slide is reached. But calling "pause" then "stop" will immediately trigger that pause effect.

"Stop" will normally bring the slider back to its starting position, but by immediately restoring the css position, there is no perceptible change. And that same position will be used on resume to achieve the desired effect.

brongo avatar May 18 '17 01:05 brongo