From d69427eac0f89bdac5e6643def3c0d558aa39d42 Mon Sep 17 00:00:00 2001 From: Manu MA Date: Tue, 11 Dec 2018 01:32:28 +0100 Subject: [PATCH] fix(angular): swipeBackEnabled global config (#16668) fixes #16624 --- angular/src/directives/navigation/ion-router-outlet.ts | 5 ++++- core/src/utils/gesture/swipe-back.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/angular/src/directives/navigation/ion-router-outlet.ts b/angular/src/directives/navigation/ion-router-outlet.ts index 970b5ccb91..d3677ab689 100644 --- a/angular/src/directives/navigation/ion-router-outlet.ts +++ b/angular/src/directives/navigation/ion-router-outlet.ts @@ -4,6 +4,7 @@ import { StackController } from './stack-controller'; import { NavController } from '../../providers/nav-controller'; import { bindLifecycleEvents } from '../../providers/angular-delegate'; import { RouteView, getUrl } from './stack-utils'; +import { Config } from '../../providers'; @Directive({ selector: 'ion-router-outlet', @@ -34,6 +35,7 @@ export class IonRouterOutlet implements OnDestroy, OnInit { @Input() set swipeGesture(swipe: boolean) { this._swipeGesture = swipe; + this.nativeEl.swipeHandler = (swipe && this.hasStack) ? { canStart: () => this.stackCtrl.canGoBack(1), onStart: () => this.stackCtrl.startBackTransition(), @@ -48,6 +50,7 @@ export class IonRouterOutlet implements OnDestroy, OnInit { @Attribute('name') name: string, @Optional() @Attribute('tabs') tabs: string, private changeDetector: ChangeDetectorRef, + private config: Config, navCtrl: NavController, elementRef: ElementRef, router: Router, @@ -82,7 +85,7 @@ export class IonRouterOutlet implements OnDestroy, OnInit { } this.nativeEl.componentOnReady().then(() => { if (this._swipeGesture === undefined) { - this.swipeGesture = this.nativeEl.mode === 'ios'; + this.swipeGesture = this.config.get('swipeBackEnabled', this.nativeEl.mode === 'ios'); } }); } diff --git a/core/src/utils/gesture/swipe-back.ts b/core/src/utils/gesture/swipe-back.ts index 56ae0c98f0..381c4ec8e0 100644 --- a/core/src/utils/gesture/swipe-back.ts +++ b/core/src/utils/gesture/swipe-back.ts @@ -12,7 +12,7 @@ export function createSwipeBackGesture( ): Gesture { const win = el.ownerDocument!.defaultView!; function canStart(detail: GestureDetail) { - return detail.startX <= 5000 && canStartHandler(); + return detail.startX <= 50 && canStartHandler(); } function onMove(detail: GestureDetail) {