mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-16 10:01:59 +08:00
fix(vue): swipe back gesture is properly disabled when swipeBackEnabled config is false (#22568)
resolves #22567
This commit is contained in:
@ -12,7 +12,7 @@ import {
|
|||||||
} from 'vue';
|
} from 'vue';
|
||||||
import { AnimationBuilder, LIFECYCLE_DID_ENTER, LIFECYCLE_DID_LEAVE, LIFECYCLE_WILL_ENTER, LIFECYCLE_WILL_LEAVE } from '@ionic/core';
|
import { AnimationBuilder, LIFECYCLE_DID_ENTER, LIFECYCLE_DID_LEAVE, LIFECYCLE_WILL_ENTER, LIFECYCLE_WILL_LEAVE } from '@ionic/core';
|
||||||
import { matchedRouteKey, useRoute } from 'vue-router';
|
import { matchedRouteKey, useRoute } from 'vue-router';
|
||||||
import { fireLifecycle, generateId } from '../utils';
|
import { fireLifecycle, generateId, getConfig } from '../utils';
|
||||||
|
|
||||||
let viewDepthKey: InjectionKey<0> = Symbol(0);
|
let viewDepthKey: InjectionKey<0> = Symbol(0);
|
||||||
export const IonRouterOutlet = defineComponent({
|
export const IonRouterOutlet = defineComponent({
|
||||||
@ -62,6 +62,10 @@ export const IonRouterOutlet = defineComponent({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const canStart = () => {
|
const canStart = () => {
|
||||||
|
const config = getConfig();
|
||||||
|
const swipeEnabled = config && config.get('swipeBackEnabled', ionRouterOutlet.value.mode === 'ios');
|
||||||
|
if (!swipeEnabled) return false;
|
||||||
|
|
||||||
const stack = viewStacks.getViewStack(id);
|
const stack = viewStacks.getViewStack(id);
|
||||||
if (!stack || stack.length <= 1) return false;
|
if (!stack || stack.length <= 1) return false;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Ref, ComponentPublicInstance } from 'vue';
|
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;
|
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]();
|
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;
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user