문제

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 
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top