metafizzy / flickity

:leaves: Touch, responsive, flickable carousels
https://flickity.metafizzy.co
7.52k stars 605 forks source link

pauseAutoPlayOnHover: true - resuming after clicking #1058

Closed joanna-s closed 4 years ago

joanna-s commented 4 years ago

Hello,

I'm using pauseAutoPlayOnHover: true and have found that hover does indeed pause the slider and it resumes on mouseout.

If the selected slide is clicked, the slider doesn't resume on mouseout.

EDIT: it does say this in your docs so sorry about raising this as an issue.

Would you be able to advise how I could stop clicking from stopping autoplay altogether?

Kind regards

Jo

desandro commented 4 years ago

autoPlay is designed to stop and stay stopped any time the user interacts with the carousel. This gives user control and does not take it away from the user. On mobile, there is no hover event so there is no way to detect when a cursor has exited the carousel.

If you wish to implement that behavior, you can do so with your own JS and the Flickity API. You likely want to trigger playPlayer after mouseout.

Similar to #734

joanna-s commented 4 years ago

@desandro Great thank you! Sorry for leaving this as an issue, when it's not! Hope I've not caused any inconvenience... Thanks for the awesome slider by the way, it's now my go to after tiring of Slick's lack of swipe control :)

MikeyJN commented 4 years ago

Hi Joanna,

I Have two solutions to help with this - the first one:

$(".main-carousel").on("mouseleave", function() {
    $(this).flickity("playPlayer");
});

And this second option (which is better IMO as 'mouseleave' doesn't work great on touch-screen devices of course!):

Flickity.prototype.stopPlayer = function() {
    this.player.stop();
    this.player.play();
};

Hope this helps,

Mike

joanna-s commented 4 years ago

@MikeyJN thanks a lot! I'll give that a shot when I get back onto that project :D

joanna-s commented 4 years ago

Worked a treat, cheers @MikeyJN