From 44b1535387c326ed69fc239d38dbdb9776b629c2 Mon Sep 17 00:00:00 2001 From: rdlabo Date: Wed, 23 Sep 2026 13:38:47 +0900 Subject: [PATCH] feat(transition): allow themes to omit fixed back-button animation --- src/transition/ios.transition.spec.ts | 29 +++++++++++++++++++++++++++ src/transition/ios.transition.ts | 4 +++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/transition/ios.transition.spec.ts b/src/transition/ios.transition.spec.ts index b1de84a..0ab5341 100644 --- a/src/transition/ios.transition.spec.ts +++ b/src/transition/ios.transition.spec.ts @@ -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'; diff --git a/src/transition/ios.transition.ts b/src/transition/ios.transition.ts index cd0c2db..e19d903 100644 --- a/src/transition/ios.transition.ts +++ b/src/transition/ios.transition.ts @@ -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`). @@ -277,7 +279,7 @@ export const createIosTransitionAnimation =