From 97dd713485ca3cd138c3068c2ef52a4968a5af50 Mon Sep 17 00:00:00 2001 From: Janne Julkunen Date: Wed, 24 Jan 2018 16:11:59 +0200 Subject: [PATCH] Fixed disabled control to work with latest Swiper --- example/src/app/app.component.html | 4 ++-- src/lib/swiper.directive.ts | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/example/src/app/app.component.html b/example/src/app/app.component.html index a1c7d50..b39d52c 100644 --- a/example/src/app/app.component.html +++ b/example/src/app/app.component.html @@ -28,7 +28,7 @@
Swiper
- +
{{slide}} @@ -36,7 +36,7 @@
-
+
diff --git a/src/lib/swiper.directive.ts b/src/lib/swiper.directive.ts index 5d68fda..dcf4b98 100644 --- a/src/lib/swiper.directive.ts +++ b/src/lib/swiper.directive.ts @@ -111,6 +111,11 @@ export class SwiperDirective implements OnInit, DoCheck, OnDestroy, OnChanges { }; } + if (this.disabled) { + params.allowSlidePrev = false; + params.allowSlideNext = false; + } + if (this.initialIndex != null) { params.initialSlide = this.initialIndex; @@ -189,11 +194,15 @@ export class SwiperDirective implements OnInit, DoCheck, OnDestroy, OnChanges { if (changes['disabled'].currentValue !== changes['disabled'].previousValue) { if (changes['disabled'].currentValue === true) { this.zone.runOutsideAngular(() => { - this.instance.lockSwipes(); + this.ngOnDestroy(); + + this.ngOnInit(); }); } else if (changes['disabled'].currentValue === false) { this.zone.runOutsideAngular(() => { - this.instance.unlockSwipes(); + this.ngOnDestroy(); + + this.ngOnInit(); }); } }