当Swiper滑块附加新幻灯片页面向上移动时

时间:2016-11-03 10:15:42

标签: javascript jquery swiper

我在Swiper Slider上遇到麻烦,我在脚本中使用“appendSlide”,当我滚动到页脚,swiper附加新幻灯片,页面向上滚动到滑块

var mySwiper = new Swiper('.swiper-container', {
        // Optional parameters
        direction: 'horizontal',
        slidesPerView: '1',
        touchRatio: '1',
        loop: true,
        nextButton: '.swiper-button-next',
        prevButton: '.swiper-button-prev'
    });

function loadcontent () {
    var id = $('.catslide>.swiper-wrapper>.swiper-slide-active').attr('data-id');
    $.ajax({
        type: "POST",
        url: "../showthis.php",
        data: {
            id:id,
            rand:1
        },
        datatype: 'json',
        success: function (data) {
            mySwiper.removeAllSlides();
            mySwiper.appendSlide(data);
            mySwiper.update();
        }
    });
}
 categories.on('slideChangeStart', function () {
        loadcontent();
    });

0 个答案:

没有答案