mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
fix(ios): hide leaving view after nav transition to avoid flicker (#19691)
fixes #19674
This commit is contained in:
@ -223,6 +223,19 @@ const setZIndex = (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getIonPageElement = (element: HTMLElement) => {
|
||||||
|
if (element.classList.contains('ion-page')) {
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ionPage = element.querySelector(':scope > .ion-page, :scope > ion-nav, :scope > ion-tabs');
|
||||||
|
if (ionPage) {
|
||||||
|
return ionPage;
|
||||||
|
}
|
||||||
|
// idk, return the original element so at least something animates and we don't have a null pointer
|
||||||
|
return element;
|
||||||
|
};
|
||||||
|
|
||||||
export interface TransitionOptions extends NavOptions {
|
export interface TransitionOptions extends NavOptions {
|
||||||
progressCallback?: ((ani: Animation | undefined) => void);
|
progressCallback?: ((ani: Animation | undefined) => void);
|
||||||
baseEl: any;
|
baseEl: any;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Animation } from '../../interface';
|
import { Animation } from '../../interface';
|
||||||
import { createAnimation } from '../animation/animation';
|
import { createAnimation } from '../animation/animation';
|
||||||
import { TransitionOptions } from '../transition';
|
import { TransitionOptions, getIonPageElement } from '../transition';
|
||||||
|
|
||||||
const DURATION = 540;
|
const DURATION = 540;
|
||||||
const addSafeArea = (val: number, side = 'top'): string => {
|
const addSafeArea = (val: number, side = 'top'): string => {
|
||||||
@ -376,6 +376,13 @@ export const iosTransitionAnimation = (navEl: HTMLElement, opts: TransitionOptio
|
|||||||
.beforeClearStyles([OPACITY])
|
.beforeClearStyles([OPACITY])
|
||||||
.fromTo('transform', `translateX(${CENTER})`, (isRTL ? 'translateX(-100%)' : 'translateX(100%)'));
|
.fromTo('transform', `translateX(${CENTER})`, (isRTL ? 'translateX(-100%)' : 'translateX(100%)'));
|
||||||
|
|
||||||
|
const leavingPage = getIonPageElement(leavingEl) as HTMLElement;
|
||||||
|
rootAnimation.afterAddWrite(() => {
|
||||||
|
if (rootAnimation.getDirection() === 'normal') {
|
||||||
|
leavingPage.style.setProperty('display', 'none');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// leaving content, forward direction
|
// leaving content, forward direction
|
||||||
leavingContent
|
leavingContent
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Animation } from '../../interface';
|
import { Animation } from '../../interface';
|
||||||
import { createAnimation } from '../animation/animation';
|
import { createAnimation } from '../animation/animation';
|
||||||
import { TransitionOptions } from '../transition';
|
import { TransitionOptions, getIonPageElement } from '../transition';
|
||||||
|
|
||||||
export const mdTransitionAnimation = (_: HTMLElement, opts: TransitionOptions): Animation => {
|
export const mdTransitionAnimation = (_: HTMLElement, opts: TransitionOptions): Animation => {
|
||||||
const OFF_BOTTOM = '40px';
|
const OFF_BOTTOM = '40px';
|
||||||
@ -59,16 +59,3 @@ export const mdTransitionAnimation = (_: HTMLElement, opts: TransitionOptions):
|
|||||||
|
|
||||||
return rootTransition;
|
return rootTransition;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getIonPageElement = (element: HTMLElement) => {
|
|
||||||
if (element.classList.contains('ion-page')) {
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ionPage = element.querySelector(':scope > .ion-page, :scope > ion-nav, :scope > ion-tabs');
|
|
||||||
if (ionPage) {
|
|
||||||
return ionPage;
|
|
||||||
}
|
|
||||||
// idk, return the original element so at least something animates and we don't have a null pointer
|
|
||||||
return element;
|
|
||||||
};
|
|
||||||
|
Reference in New Issue
Block a user