admin管理员组文章数量:1401417
i'm setting up swiper.js library (/) and i have a problem with settings. I'm try to setup swiper to start autoplay on desktop size and stop autoplay on mobile (eg. 768px down). Everything work fine on desktop and even if you try responsive without refresh page. Problem begin on mobile size after page refresh. Swiper ignore all settings until page resize.
Demo:
var swiper = new Swiper('.swiper-container', {
autoplay: {
delay: 1000
},
breakpoints: {
768: {
autoplay: {
delay: false
}
}
},
pagination: {
el: '.swiper-pagination',
clickable: true,
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
});
Anyone know what i'm doing wrong? Thanks
i'm setting up swiper.js library (http://idangero.us/swiper/) and i have a problem with settings. I'm try to setup swiper to start autoplay on desktop size and stop autoplay on mobile (eg. 768px down). Everything work fine on desktop and even if you try responsive without refresh page. Problem begin on mobile size after page refresh. Swiper ignore all settings until page resize.
Demo: https://codepen.io/anon/pen/WWdera
var swiper = new Swiper('.swiper-container', {
autoplay: {
delay: 1000
},
breakpoints: {
768: {
autoplay: {
delay: false
}
}
},
pagination: {
el: '.swiper-pagination',
clickable: true,
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
});
Anyone know what i'm doing wrong? Thanks
Share Improve this question asked Apr 16, 2019 at 10:37 A. MrazA. Mraz 332 silver badges6 bronze badges2 Answers
Reset to default 4This works after reboot. You need to change the autoplay object to boolean
var swiper = new Swiper('.swiper-container', {
autoplay: {
delay: 1000
},
breakpoints: {
768: {
autoplay: false
}
},
pagination: {
el: '.swiper-pagination',
clickable: true,
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
});
In swiper v9.2.2, and with help from @MNN TNK's ment, I had to use the following to disable autoplay on mobile...
var swiper = new Swiper('.swiper-container', {
autoplay: {
enabled: false,
},
breakpoints: {
768: {
autoplay: {
enabled: true,
delay: 1000,
}
}
},
...
}
本文标签: javascriptSwiperjs breakpoints autoplay issueStack Overflow
版权声明:本文标题:javascript - Swiper.js breakpoints autoplay issue - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744305439a2599788.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论