Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/transition/ios.transition.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,35 @@ describe('createIosTransitionAnimation radius', () => {
});

describe('createIosTransitionAnimation fixed back button', () => {
it('omits only its clone when the host opts out', () => {
const nav = document.createElement('ion-router-outlet');
const enteringEl = createPage(true);
const button = document.createElement('ion-back-button');
enteringEl.querySelector('ion-header')!.append(button);
nav.append(enteringEl);
document.body.append(nav);

Object.defineProperty(button, 'offsetWidth', { configurable: true, value: 40 });
const clone = document.createElement('ion-back-button');
clone.classList.add('ion-cloned-element');
document.body.append(clone);

const animation = createIosTransitionAnimation({
offLeftPercent: 30,
getIonPageElement: (element) => element,
shouldAnimateFixedBackButton: () => false,
})(nav, { enteringEl });
animation.progressStart(true);

expect(clone.parentElement).toBe(document.body);
expect(button.style.visibility).toBe('');
expect(animation.childAnimations.some((child) => child.elements.includes(enteringEl))).toBe(true);

animation.destroy();
nav.remove();
clone.remove();
});

it('measures its coordinates when the transition starts', () => {
const documentDirection = document.dir;
document.dir = 'rtl';
Expand Down
4 changes: 3 additions & 1 deletion src/transition/ios.transition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export interface IosTransitionAnimationConfig {
radius?: number;
/** Resolves the ion-page (or fallback) element for a leaving view. */
getIonPageElement: (element: HTMLElement) => Element;
/** Whether the fixed back button participates in the page transition. */
shouldAnimateFixedBackButton?: (navEl: HTMLElement) => boolean;
/**
* Optional hook invoked after the root animation is fully composed
* (e.g. ios27 `connectNativeUIShellTransition`).
Expand Down Expand Up @@ -277,7 +279,7 @@ export const createIosTransitionAnimation = <TOpts extends IosTransitionAnimatio
}
}

if (topPage) {
if (topPage && config.shouldAnimateFixedBackButton?.(navEl) !== false) {
animateFixedBackButton(
rootAnimation,
navEl,
Expand Down
Loading