jQuery cycle plugin stop sliding after switching to another tab

雨燕双飞 提交于 2020-01-02 09:55:45

问题


I am using jquery cycle plugin with below settings.Photos sliding in given time out well without problem but if i click another tab of browser and wait 10 sn then back to slideshow's tab and i see that slideshow is stopped . It does not pass next photo. What can cause this problem ?

    var slideShow = $('.slideshow-container').cycle({ fx: 'fade', timeout: 3000, speed: 500, fastOnEvent: 1,
        skipInitializationCallbacks: true,
        pause: 1
    });

I am using jQuery 1.6.2 and cycle version 2.9995 (latest).

You can Test it on jsfiddle.net


回答1:


All right, I think I got it. It's working now, at least with the options specified by your code. I'm not sure (for I have not tested it) if my implementation will play along nicely with other options that can be passed to cycle plugin.

The reason why this problem has been occuring was that next iteration where transition suppose to occure was setup before completion of previous transition. In some cases, next transition was fired before the previous has finished, at the beginning of that new transition there's a check whenever there's already other animation going on - if so, the function would just return and stop (without setting up next iteration). After the ongoing animation was finished, the slideshow was stopped, because there was no next transition scheduled.

I've forked the cycle plugin on github and published my fix: https://github.com/WTK/cycle



来源:https://stackoverflow.com/questions/7316988/jquery-cycle-plugin-stop-sliding-after-switching-to-another-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!