最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to disable clicking and touchmouse dragging while slide is changing in Swiper Js - Stack Overflow

programmeradmin2浏览0评论

I added some animation with GSAP for my slider, which I get from Swiper JS / and everything working fine, but if user will click many times on Swiper navigation (arrows, dots or dragging) my animation starts to crash. So question is how can I disable clicking or swiping while slide is changing? I have simple code:

var modernSlider = new Swiper ('.swiper-container', {
    slidesPerView: 1,
    centerSlides: true,
    pagination: {
        el: '.swiper-pagination',
        clickable: true,
      },
    navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
      },
})
modernSlider.on('slideChange', function(){
        var $self = $('.swiper-slide');
        var $tSpan = $self.find('.text h1 span');
        gsap.to($tSpan, {
            duration: 0.4,
            y: '50px'
        })
})

Can you help me, please? Thanks in advance!

I added some animation with GSAP for my slider, which I get from Swiper JS https://swiperjs./ and everything working fine, but if user will click many times on Swiper navigation (arrows, dots or dragging) my animation starts to crash. So question is how can I disable clicking or swiping while slide is changing? I have simple code:

var modernSlider = new Swiper ('.swiper-container', {
    slidesPerView: 1,
    centerSlides: true,
    pagination: {
        el: '.swiper-pagination',
        clickable: true,
      },
    navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
      },
})
modernSlider.on('slideChange', function(){
        var $self = $('.swiper-slide');
        var $tSpan = $self.find('.text h1 span');
        gsap.to($tSpan, {
            duration: 0.4,
            y: '50px'
        })
})

Can you help me, please? Thanks in advance!

Share Improve this question asked Jan 15, 2020 at 16:50 AslanAslan 1053 silver badges14 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

swiper have a property called noSwiping set it in config object to false.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论