Owl-carousel 2 stop the work of autoplay when lose a focus

99封情书 提交于 2019-12-02 03:39:46

问题


I use Owl-carousel 2. I use standard code of initialization and markup of Owl-carousel 2. At the first load of page the work of carousel is perfect. Owl-carousel 2 stop the work when I pass in browser to another page and back or minimize browser and again open page with Owl-carousel 2. New start of carousel when I again click navigation. I had try to place in body of html code of initialization of carousel again:

var $carousel = $('.owl-carousel');
var owl = $carousel.data('owlCarousel');
owl.trigger("refresh.owl.carousel");

But it is not working. Autoplay need to run but it is not working. How I can correct this problem? Thanks


回答1:


I know this question is rather old, but since it has no answer yet, and the issue is still present in Owl Carousel 2.2.1, here's a simple solution that may hopefully help someone:

Try using the beta build of Owl Carousel, you can get it here. Just grab the owl.carousel.js or owl.carousel.min.js file and replace the one you're using currently with it. At the moment of this writing the current beta build is 2.3.0. I can confirm that this build fixed the issue for me.


The issue is a known bug. The discussion in the issue tracker provides more insight into what causes it, so you could use it to modify your existing owl.carousel.js to incorporate your own fix if you don't feel like using beta builds.



来源:https://stackoverflow.com/questions/40316834/owl-carousel-2-stop-the-work-of-autoplay-when-lose-a-focus

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