swiper2.x 怎样才能才能实现淡出淡入效果,swiper3.x可以实现但兼容性不好
1个回答
2015-06-05
展开全部
可以利用progress实现
<script>
var mySwiper = new Swiper('.swiper-container',{
progress:true,
onProgressChange: function(swiper){
for (var i = 0; i < swiper.slides.length; i++){
var slide = swiper.slides[i];
var progress = slide.progress;
var translate = progress*swiper.width;
var opacity = 1 - Math.min(Math.abs(progress),1);
slide.style.opacity = opacity;
swiper.setTransform(slide,'translate3d('+translate+'px,0,0)');
}
},
onTouchStart:function(swiper){
for (var i = 0; i < swiper.slides.length; i++){
swiper.setTransition(swiper.slides[i], 0);
}
},
onSetWrapperTransition: function(swiper, speed) {
for (var i = 0; i < swiper.slides.length; i++){
swiper.setTransition(swiper.slides[i], speed);
}
}
})
</script>
参考:Swiper中文网
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询