Slides - how to disable swipe between slides (with gestures)?


#1

Do you know any solutions? I need to allow only change slides using:
slidesId.next()


#2

You can disable swipe gestures by passing options to the slider:

<ion-slides class="slides" [options]="{onlyExternal: false}">
  <ion-slide>
    <p>First Slide</p>
  </ion-slide>
  <ion-slide>
    <p>Second Slide</p>
  </ion-slide>
</ion-slides>

Here you can find more options: http://www.idangero.us/swiper/api/

Does anyone know how to access the slider object?


#3

Thanks for reply!

Getting access the slider object is here


#4

Not directly an answer to your use case but just in case someone is wondering. In order to disable/enable swiping of slides dynamically I had to use the following:


>     let swiperInstance = this.slider.getSlider();
>     if (shouldSwipe == true){
>       swiperInstance.unlockSwipes();`
>     } else {
>       swiperInstance.lockSwipes();
>     }

according to SwiperAPI and Slides - Ionic API


#5

lockSwipes() should do the job
this.slider.lockSwipes(true);

This how i managed the lock
next() { if (!this.editMode) { this.signupSlider.lockSwipes(false) this.signupSlider.slideNext(); this.signupSlider.lockSwipes(true) } else { this.signupSlider.slideNext(); } }


#6

[options]="{onlyExternal: false}"

This option didn’t work for me.


#7

Please help me not working for me as well


#8

unexpected token. please help


#9

Looking at the Swiper API, you can add the noSwipingClass to your options.

example:

scope.options = {
	loop: false,
	noSwipingClass: 'swiper-no-swiping',
	effect: 'slide',
	speed: 500
}

Assuming you’re using ionic v1, you can then just add the specified class to your ion-slide-page.

<ion-slide-page class="swiper-no-swiping">

#10

Class works for ionic v2+ as well


#11

<ion-slide-page class=“swiper-no-swiping”>

Work!


#12

this.slides.lockSwipes(true); // this will disable the swipe in either ways
this.slides.lockSwipes(false); // this will enable the swipe in either ways


#13

Simplest answer here, works a charm, thanks!