I have a slideshow running with the awesome cycle plugin, and when you click a button in the show, I show a hidden layer on the page and send a 'pause' command to cycle. I'm having two problems:
When the pause command is received, cycle immediately flips back to the 1st slide in the sequence (why??), and doesn't hit my before/after callbacks.
After closing the layer, I send a 'resume' command to cycle. The slideshow resumes (from the 1st slide, where the pause left it), but now cycle doesn't call my before/after callbacks at all, even as the slideshow progresses.
So I guess my question is: how can I properly pause/resume the slideshow so these strange behaviors don't occur? (And just to be completely clear and avoid any confusion, this isn't about the "pause on hover" feature, which is actually working fine for me. :-)
Here's my cycle() init, and my callback functions. (Why am I manually tracking the nextSlide, you ask? Because the built-in value for the current slide doesn't get updated properly for the before/after callbacks.)
$(document).ready(function() {
$('#slideshow').cycle({
fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
timeout: 4000, // milliseconds between slide transitions (0 to disable auto advance)
speed: 1000, // speed of the transition (any valid fx speed value)
pause: 1, // true to enable "pause on hover"
delay: 0, // additional delay (in ms) for first transition (hint: can be negative)
slideExpr: 'img', // expression for selecting slides (if something other than all children is required)
before: moveArrow, // function to call when moving to next slide
after: upd, // function to call when moving to next slide
fastOnEvent: 'fast',
});
});
var nextSlide = 0;
function upd(a, b, c) {
nextSlide = nextSlide + 1; // track which slide we're on
c = $('#slideshow img').length;
if(nextSlide > (c - 1)) nextSlide = 0; // wrap back to 1st
}
// move indicator showing which slide we're on
function moveArrow(a, b, c) {
$('#slide-indicator').attr('class', 'c'+nextSlide);
$(".clickmap").hide(); // hide other clickmaps
$(".clickmap.c"+nextSlide).show(); // show map for this slide
return true;
}
Thanks for any thoughts on this--
best, Eric