ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
50.94k stars 13.52k forks source link

[Ionic v4] Slides. lockSwipes, lockSwipeToNext and lockSwipeToPrev, slideNext, slidePrev etc. seems to have no effect #14989

Closed peterpeterparker closed 6 years ago

peterpeterparker commented 6 years ago

Ionic Info @ionic/angular: "4.0.0-beta.1"

Describe the Bug I tried

@ViewChild('mySlider') private slides: ElementRef;

slides.nativeElement.lockSwipes()
slides.nativeElement.lockSwipeToNext()
slides.nativeElement.lockSwipeToPrev()

as described in the documentation https://beta.ionicframework.com/docs/api/slides in order to block my slider but none had effects, it was still possible to swipe the slider

Expected Behavior If my understanding is correct, I would except these functions to block the slide/swipe ability of the sliders

Workaround Settings the following options to a slides block the swipe

<ion-slides [options]="myOptions"></ion-slides>

myOptions: SwiperOptions = {
    allowSlideNext: false,
    allowSlidePrev: false
};

UPDATE

Just tried also slides.nativeElement.slidePrev or slides.nativeElement.slideNext which didn't had effects neither. I am doing something wrong or these just don't work?

peterpeterparker commented 6 years ago

Fck me, the problem was between the keyboard and the screen aka me

If you use lock the swiper using options like allowSlideNext oder allowSlidePrev then you can't use slidePrev and slideNext, it's defined like this in the swiper

What I was actually looking for is the option allowTouchMove

// No user slide authorized but slide from the code authorized
slideOpts: SwiperOptions = {
    allowTouchMove: false
};

References:

Documentation - http://idangero.us/swiper/api/ And that Ionic issue - https://github.com/ionic-team/ionic/issues/10207 - thx to @jgerstle for his comment which makes me realize my mistake

ionitron-bot[bot] commented 6 years ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.