search

Home  >  Q&A  >  body text

javascript - swiper.js has nested swiper. The initial setting cannot slide to the next one. Re-initialize after the end.

 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动画
        }
    });
    

Drag and drop completed

 swiperV.allowSwipeToNext=true;

How to re-initialize

漂亮男人漂亮男人2755 days ago865

reply all(1)I'll reply

  • 女神的闺蜜爱上我

    女神的闺蜜爱上我2017-06-28 09:29:46

    I happen to be using Swiper recently, but there is no need to re-initialize it. I took a look at the documentation:

    Updating the configuration should be through the paramsattribute:

    swiperV.params.allowSwipeToNext = true;

    Then it needs to be reinitialized:

    swiperV.reInit(); // 2.x
    swiperV.update(); // 3.x

    reply
    0
  • Cancelreply