Skip to content

Commit 70e0562

Browse files
committed
fix(ios): hide leaving view after nav transition to avoid flicker (#19691)
fixes #19674
1 parent b7baf24 commit 70e0562

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

core/src/utils/transition/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,19 @@ const setZIndex = (
243243
}
244244
};
245245

246+
export const getIonPageElement = (element: HTMLElement) => {
247+
if (element.classList.contains('ion-page')) {
248+
return element;
249+
}
250+
251+
const ionPage = element.querySelector(':scope > .ion-page, :scope > ion-nav, :scope > ion-tabs');
252+
if (ionPage) {
253+
return ionPage;
254+
}
255+
// idk, return the original element so at least something animates and we don't have a null pointer
256+
return element;
257+
};
258+
246259
export interface TransitionOptions extends NavOptions {
247260
progressCallback?: ((ani: IonicAnimation | Animation | undefined) => void);
248261
baseEl: any;

core/src/utils/transition/ios.transition.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { IonicAnimation } from '../../interface';
22
import { createAnimation } from '../animation/animation';
3-
import { TransitionOptions } from '../transition';
3+
import { TransitionOptions, getIonPageElement } from '../transition';
44

55
const DURATION = 540;
66
const addSafeArea = (val: number, side = 'top'): string => {
@@ -376,6 +376,13 @@ export const iosTransitionAnimation = (navEl: HTMLElement, opts: TransitionOptio
376376
.beforeClearStyles([OPACITY])
377377
.fromTo('transform', `translateX(${CENTER})`, (isRTL ? 'translateX(-100%)' : 'translateX(100%)'));
378378

379+
const leavingPage = getIonPageElement(leavingEl) as HTMLElement;
380+
rootAnimation.afterAddWrite(() => {
381+
if (rootAnimation.getDirection() === 'normal') {
382+
leavingPage.style.setProperty('display', 'none');
383+
}
384+
});
385+
379386
} else {
380387
// leaving content, forward direction
381388
leavingContent

core/src/utils/transition/md.transition.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { IonicAnimation } from '../../interface';
22
import { createAnimation } from '../animation/animation';
3-
import { TransitionOptions } from '../transition';
3+
import { TransitionOptions, getIonPageElement } from '../transition';
44

55
export const mdTransitionAnimation = (_: HTMLElement, opts: TransitionOptions): IonicAnimation => {
66
const OFF_BOTTOM = '40px';
@@ -59,16 +59,3 @@ export const mdTransitionAnimation = (_: HTMLElement, opts: TransitionOptions):
5959

6060
return rootTransition;
6161
};
62-
63-
const getIonPageElement = (element: HTMLElement) => {
64-
if (element.classList.contains('ion-page')) {
65-
return element;
66-
}
67-
68-
const ionPage = element.querySelector(':scope > .ion-page, :scope > ion-nav, :scope > ion-tabs');
69-
if (ionPage) {
70-
return ionPage;
71-
}
72-
// idk, return the original element so at least something animates and we don't have a null pointer
73-
return element;
74-
};

0 commit comments

Comments
 (0)