Skip to content

Commit

Permalink
fix(ios): hide leaving view after nav transition to avoid flicker (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
liamdebeasi committed Oct 21, 2019
1 parent b7baf24 commit 70e0562
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
13 changes: 13 additions & 0 deletions core/src/utils/transition/index.ts
Expand Up @@ -243,6 +243,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 {
progressCallback?: ((ani: IonicAnimation | Animation | undefined) => void);
baseEl: any;
Expand Down
9 changes: 8 additions & 1 deletion core/src/utils/transition/ios.transition.ts
@@ -1,6 +1,6 @@
import { IonicAnimation } from '../../interface';
import { createAnimation } from '../animation/animation';
import { TransitionOptions } from '../transition';
import { TransitionOptions, getIonPageElement } from '../transition';

const DURATION = 540;
const addSafeArea = (val: number, side = 'top'): string => {
Expand Down Expand Up @@ -376,6 +376,13 @@ export const iosTransitionAnimation = (navEl: HTMLElement, opts: TransitionOptio
.beforeClearStyles([OPACITY])
.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 {
// leaving content, forward direction
leavingContent
Expand Down
15 changes: 1 addition & 14 deletions core/src/utils/transition/md.transition.ts
@@ -1,6 +1,6 @@
import { IonicAnimation } from '../../interface';
import { createAnimation } from '../animation/animation';
import { TransitionOptions } from '../transition';
import { TransitionOptions, getIonPageElement } from '../transition';

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

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;
};

0 comments on commit 70e0562

Please sign in to comment.