var lihong = document.getElementById('interact');
var swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
paginationClickable: true,
watchSlidesProgress : true,
direction: 'vertical',
onInit: function(swiper){ //Swiper2.x的初始化是onFirstInit
swiperAnimateCache(swiper); //隐藏动画元素
swiperAnimate(swiper); //初始化完成开始动画
},
onSlideChangeEnd: function(swiper){
swiperAnimate(swiper); //每个slide切换结束时也运行当前slide动画
if (swiper.realIndex>0) {
alert(swiper.activeIndex)
lihong.setAttribute('style','display:block');
}else{
lihong.setAttribute('style','display:none');
};
}
});
swiper.realIndex 当前是第几页(从0开始),配合onSlideChangeEnd做判断完成一些事情。
*swiper的回调函数onSlideChangeEnd 这个函数可以在slide切换结束时做很多动作。