fix(vue): swipe back gesture is properly disabled when swipeBackEnabled config is false (#22568)

resolves #22567
This commit is contained in:
Liam DeBeasi
2020-11-30 10:59:00 -05:00
committed by GitHub
parent 181fc59ab7
commit 9d04c127e8
2 changed files with 16 additions and 2 deletions

View File

@ -12,7 +12,7 @@ import {
} from 'vue';
import { AnimationBuilder, LIFECYCLE_DID_ENTER, LIFECYCLE_DID_LEAVE, LIFECYCLE_WILL_ENTER, LIFECYCLE_WILL_LEAVE } from '@ionic/core';
import { matchedRouteKey, useRoute } from 'vue-router';
import { fireLifecycle, generateId } from '../utils';
import { fireLifecycle, generateId, getConfig } from '../utils';
let viewDepthKey: InjectionKey<0> = Symbol(0);
export const IonRouterOutlet = defineComponent({
@ -62,6 +62,10 @@ export const IonRouterOutlet = defineComponent({
});
const canStart = () => {
const config = getConfig();
const swipeEnabled = config && config.get('swipeBackEnabled', ionRouterOutlet.value.mode === 'ios');
if (!swipeEnabled) return false;
const stack = viewStacks.getViewStack(id);
if (!stack || stack.length <= 1) return false;

View File

@ -1,5 +1,5 @@
import { Ref, ComponentPublicInstance } from 'vue';
import { LIFECYCLE_DID_ENTER, LIFECYCLE_DID_LEAVE, LIFECYCLE_WILL_ENTER, LIFECYCLE_WILL_LEAVE } from '@ionic/core';
import { Config as CoreConfig, LIFECYCLE_DID_ENTER, LIFECYCLE_DID_LEAVE, LIFECYCLE_WILL_ENTER, LIFECYCLE_WILL_LEAVE } from '@ionic/core';
type LIFECYCLE_EVENTS = typeof LIFECYCLE_WILL_ENTER | typeof LIFECYCLE_DID_ENTER | typeof LIFECYCLE_WILL_LEAVE | typeof LIFECYCLE_DID_LEAVE;
@ -22,3 +22,13 @@ export const fireLifecycle = (vueComponent: any, vueInstance: Ref<ComponentPubli
instance[lifecycle]();
}
}
export const getConfig = (): CoreConfig | null => {
if (typeof (window as any) !== 'undefined') {
const Ionic = (window as any).Ionic;
if (Ionic && Ionic.config) {
return Ionic.config;
}
}
return null;
};