Frage

Is there a way in Cycle2 to tell when the goto function is being skipped due to it already being on that slide.

I have some cases where it could handle and I want to handle this in a proper way, but I can't seem to find any event that's being triggered for this.

$slider.cycle('goto', 0); //[cycle2] goto: skipping, already on slide 0 
War es hilfreich?

Lösung

The code for goto doesn't fire if you are targeting the current slide. You can see this in the source code (line 951 as of this writing):

if (num == opts.currSlide) {
    opts.API.log('goto: skipping, already on slide', num);
    return;
}

If the license allows it, remove that block from the code and handle the cycle-before event that will now be fired (I didn't test it, but I assume it will!). You could also directly implement your logic there or even add a custom event yourself, depending on what you are planning to do.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top