Do you know any solutions? I need to allow only change slides using:
slidesId.next()
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?
Thanks for reply!
Getting access the slider object is here
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
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(); } }
[options]=â{onlyExternal: false}â
This option didnât work for me.
Please help me not working for me as well
unexpected token. please help
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">
Class works for ionic v2+ as well
<ion-slide-page class=âswiper-no-swipingâ>
Work!
this.slides.lockSwipes(true); // this will disable the swipe in either ways
this.slides.lockSwipes(false); // this will enable the swipe in either ways
Simplest answer here, works a charm, thanks!
How could I lock the swipe in one direction? It does not work out for me dynamically - only once I pass it to the options staticâŚ
Thanks, Olli
Canât bind to âoptionsâ since it isnât a known property of âion-slidesâ.
Use:
@ViewChild('slider') slider: Slides;
this.slider.onlyExternal = true;
That did the trick for me
@ViewChild(IonSlides) slides: IonSlides;
ngOnInit() {
this.slides.lockSwipes(true)
}
next(){
this.slides.lockSwipes(false)
this.slides.slideNext()
this.slides.lockSwipes(true)
}
previous(){
this.slides.lockSwipes(false)
this.slides.slidePrev()
this.slides.lockSwipes(true)
}
From github Matt-Jensenâs response
The following works : <ion-slides [options]="{ allowTouchMove: false }">
Thanks @MrWhite, its to work to me
class="swiper-no-swiping"
works for ionic 5+ as well!