admin管理员组文章数量:1388234
I have a slider that I want to set to autoplay and have a fade effect. Everything works fine when using the normal slide effect but after I added the fade it stops working after 1 fade. It's also not fading but just instantly changing to the next slide, only when I manually use my mouse to slide it shows a fade effect.
What could be the issue?
In my js file I import the 'EffectFade' like this:
import Swiper, {Autoplay, Navigation, Pagination, EffectFade} from 'swiper';
Swiper.use([Autoplay, Navigation, Pagination, EffectFade]);
Then my swiper code:
new Swiper('#agrarisch .swiper-container', {
slidesPerView: 1,
// spaceBetween: 30,
effect: 'fade',
autoplay: {
delay: 2500,
},
navigation: {
nextEl: '#agrarisch .swiper-button-next',
prevEl: '#agrarisch .swiper-button-prev',
}
});
Example video
I have a slider that I want to set to autoplay and have a fade effect. Everything works fine when using the normal slide effect but after I added the fade it stops working after 1 fade. It's also not fading but just instantly changing to the next slide, only when I manually use my mouse to slide it shows a fade effect.
What could be the issue?
In my js file I import the 'EffectFade' like this:
import Swiper, {Autoplay, Navigation, Pagination, EffectFade} from 'swiper';
Swiper.use([Autoplay, Navigation, Pagination, EffectFade]);
Then my swiper code:
new Swiper('#agrarisch .swiper-container', {
slidesPerView: 1,
// spaceBetween: 30,
effect: 'fade',
autoplay: {
delay: 2500,
},
navigation: {
nextEl: '#agrarisch .swiper-button-next',
prevEl: '#agrarisch .swiper-button-prev',
}
});
Example video
Share Improve this question asked Nov 4, 2022 at 10:08 twantwan 2,65912 gold badges42 silver badges116 bronze badges 1- Hey, did you ever figure this one out? I'm having the same issue! – HalesEnchanted Commented Dec 7, 2022 at 4:51
3 Answers
Reset to default 4I fixed it by including the fade effect CSS:
// Node
@import "./node_modules/swiper/swiper";
@import "./node_modules/swiper/modules/effect-fade/effect-fade";
The same problem arose for me. In my case, I solved it by loading "swiper-bundle.min.css" instead of "swiper.min.css".
Anyone struggling with autoplay effect fade in swiper slider must try this example:
var swiper = new Swiper(".home-slider", {
slidesPerView: 1,
spaceBetween: 30,
effect: "fade",
centeredSlides: true,
fadeEffect: { crossFade: true },
autoplay: {
delay: 7500,
disableOnInteraction: true,
},
pagination: {
el: ".swiper-pagination",
clickable: true,
},
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
});
本文标签: javascriptAutoplay stops after 1 fade when using fade effect in swiper jsStack Overflow
版权声明:本文标题:javascript - Autoplay stops after 1 fade when using fade effect in swiper js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744571408a2613362.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论