fix(angular): swipeBackEnabled global config (#16668)

fixes #16624
This commit is contained in:
Manu MA
2018-12-11 01:32:28 +01:00
committed by GitHub
parent 82172b6043
commit d69427eac0
2 changed files with 5 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import { StackController } from './stack-controller';
import { NavController } from '../../providers/nav-controller'; import { NavController } from '../../providers/nav-controller';
import { bindLifecycleEvents } from '../../providers/angular-delegate'; import { bindLifecycleEvents } from '../../providers/angular-delegate';
import { RouteView, getUrl } from './stack-utils'; import { RouteView, getUrl } from './stack-utils';
import { Config } from '../../providers';
@Directive({ @Directive({
selector: 'ion-router-outlet', selector: 'ion-router-outlet',
@ -34,6 +35,7 @@ export class IonRouterOutlet implements OnDestroy, OnInit {
@Input() @Input()
set swipeGesture(swipe: boolean) { set swipeGesture(swipe: boolean) {
this._swipeGesture = swipe; this._swipeGesture = swipe;
this.nativeEl.swipeHandler = (swipe && this.hasStack) ? { this.nativeEl.swipeHandler = (swipe && this.hasStack) ? {
canStart: () => this.stackCtrl.canGoBack(1), canStart: () => this.stackCtrl.canGoBack(1),
onStart: () => this.stackCtrl.startBackTransition(), onStart: () => this.stackCtrl.startBackTransition(),
@ -48,6 +50,7 @@ export class IonRouterOutlet implements OnDestroy, OnInit {
@Attribute('name') name: string, @Attribute('name') name: string,
@Optional() @Attribute('tabs') tabs: string, @Optional() @Attribute('tabs') tabs: string,
private changeDetector: ChangeDetectorRef, private changeDetector: ChangeDetectorRef,
private config: Config,
navCtrl: NavController, navCtrl: NavController,
elementRef: ElementRef, elementRef: ElementRef,
router: Router, router: Router,
@ -82,7 +85,7 @@ export class IonRouterOutlet implements OnDestroy, OnInit {
} }
this.nativeEl.componentOnReady().then(() => { this.nativeEl.componentOnReady().then(() => {
if (this._swipeGesture === undefined) { if (this._swipeGesture === undefined) {
this.swipeGesture = this.nativeEl.mode === 'ios'; this.swipeGesture = this.config.get('swipeBackEnabled', this.nativeEl.mode === 'ios');
} }
}); });
} }

View File

@ -12,7 +12,7 @@ export function createSwipeBackGesture(
): Gesture { ): Gesture {
const win = el.ownerDocument!.defaultView!; const win = el.ownerDocument!.defaultView!;
function canStart(detail: GestureDetail) { function canStart(detail: GestureDetail) {
return detail.startX <= 5000 && canStartHandler(); return detail.startX <= 50 && canStartHandler();
} }
function onMove(detail: GestureDetail) { function onMove(detail: GestureDetail) {