var swiperV = new Swiper('.swiper-container-v', {
pagination: '.swiper-pagination-v',
paginationClickable: true,
direction: 'vertical',
allowSwipeToNext: false,
observer: true,
observeParents: true
});
var swiperH = new Swiper('.swiper-container-h', {
pagination: '.swiper-pagination-h',
paginationClickable: true,
direction: 'horizontal',
resistanceRatio: 0,
prevButton: '.swiper-button-prev',
nextButton: '.swiper-button-next',
a11y: true,
initialSlide: initSceneIndex,
onInit: function (swiper) { //Swiper2.x的初始化是onFirstInit
swiperAnimateCache(swiper); //隐藏动画元素
swiperAnimate(swiper); //初始化完成开始动画
},
onSlideChangeEnd: function (swiper) {
swiperAnimate(swiper); //每个slide切换结束时也运行当前slide动画
}
});
拖曳完成
swiperV.allowSwipeToNext=true;
怎麼重新初始呢
女神的闺蜜爱上我2017-06-28 09:29:46
剛好最近也在使用 Swiper,但沒有需要重新初始化的狀況,看了一下文件:
更新配置應該是透過params
屬性吧:
swiperV.params.allowSwipeToNext = true;
然後需要重新初始化:
swiperV.reInit(); // 2.x
swiperV.update(); // 3.x