Staffan Estberg
Staffan Estberg

Reputation: 7035

jQuery Cycle 2: pause slideshow on click

I can't seem to find a way of pausing the jQuery Cycle 2 (http://jquery.malsup.com/cycle2) script on a navigation click state. What I want to do is let the slideshow run until the user clicks either the previous or next button, slide to that particular slide and then pause it.

Tried this but to no help:

$('.previous').on('click', function() {
    $('.slideshow').cycle('pause');
});

$('.next').on('click', function() {
    $('.slideshow').cycle('pause');
});

Not sure if referencing cycle in the above actually reinitiates the script?

Upvotes: 0

Views: 2550

Answers (1)

Ramin Omrani
Ramin Omrani

Reputation: 3761

I've created a JSBin that should help you.I've used .toggle() and .click() to provide the effect:

every time you click next/prev the slide goes to next/prev slide and pauses,then after you click again it resumes.

http://jsbin.com/inuvav/3

http://jsbin.com/inuvav/3/edit

Upvotes: 2

Related Questions