@rdlabo/ionic-theme-ios27 0.1.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +241 -0
  3. package/dist/css/components/ion-action-sheet.css +1 -0
  4. package/dist/css/components/ion-alert.css +1 -0
  5. package/dist/css/components/ion-button.css +1 -0
  6. package/dist/css/components/ion-card.css +1 -0
  7. package/dist/css/components/ion-content.css +1 -0
  8. package/dist/css/components/ion-datetime.css +1 -0
  9. package/dist/css/components/ion-fab.css +1 -0
  10. package/dist/css/components/ion-inputs.css +1 -0
  11. package/dist/css/components/ion-list.css +1 -0
  12. package/dist/css/components/ion-loading.css +1 -0
  13. package/dist/css/components/ion-menu.css +1 -0
  14. package/dist/css/components/ion-modal.css +1 -0
  15. package/dist/css/components/ion-picker.css +1 -0
  16. package/dist/css/components/ion-popover.css +1 -0
  17. package/dist/css/components/ion-range.css +1 -0
  18. package/dist/css/components/ion-searchbar.css +1 -0
  19. package/dist/css/components/ion-segment.css +1 -0
  20. package/dist/css/components/ion-tabs.css +1 -0
  21. package/dist/css/components/ion-toast.css +1 -0
  22. package/dist/css/components/ion-toggle.css +1 -0
  23. package/dist/css/components/ion-toolbar.css +1 -0
  24. package/dist/css/default-variables.css +1 -0
  25. package/dist/css/ionic-theme-ios26-dark-always.css +1 -0
  26. package/dist/css/ionic-theme-ios26-dark-class.css +1 -0
  27. package/dist/css/ionic-theme-ios26-dark-system.css +1 -0
  28. package/dist/css/ionic-theme-ios26.css +1 -0
  29. package/dist/css/md-ion-list-inset.css +1 -0
  30. package/dist/css/md-remove-ios-class-effect.css +1 -0
  31. package/dist/css/utils/api.css +1 -0
  32. package/dist/css/utils/dark/ion-button.css +1 -0
  33. package/dist/css/utils/dark/ion-fab.css +1 -0
  34. package/dist/css/utils/dark/ion-segment.css +1 -0
  35. package/dist/css/utils/dark/ion-tabs.css +1 -0
  36. package/dist/css/utils/searchable.css +1 -0
  37. package/dist/css/utils/structured-list.css +1 -0
  38. package/dist/css/utils/theme-dark.css +1 -0
  39. package/dist/css/utils/translucent.css +1 -0
  40. package/dist/docs.json +234 -0
  41. package/dist/focus-controller/index.d.ts +6 -0
  42. package/dist/focus-controller/index.d.ts.map +1 -0
  43. package/dist/focus-controller/index.js +62 -0
  44. package/dist/focus-controller /index.d.ts +6 -0
  45. package/dist/focus-controller /index.d.ts.map +1 -0
  46. package/dist/focus-controller /index.js +62 -0
  47. package/dist/index.d.ts +9 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +30 -0
  50. package/dist/popover/animations/ios.enter.d.ts +4 -0
  51. package/dist/popover/animations/ios.enter.d.ts.map +1 -0
  52. package/dist/popover/animations/ios.enter.js +97 -0
  53. package/dist/popover/animations/ios.leave.d.ts +3 -0
  54. package/dist/popover/animations/ios.leave.d.ts.map +1 -0
  55. package/dist/popover/animations/ios.leave.js +60 -0
  56. package/dist/popover/popover-interface.d.ts +38 -0
  57. package/dist/popover/popover-interface.d.ts.map +1 -0
  58. package/dist/popover/popover-interface.js +1 -0
  59. package/dist/popover/utils.d.ts +37 -0
  60. package/dist/popover/utils.d.ts.map +1 -0
  61. package/dist/popover/utils.js +377 -0
  62. package/dist/sheets-of-glass/animations.d.ts +8 -0
  63. package/dist/sheets-of-glass/animations.d.ts.map +1 -0
  64. package/dist/sheets-of-glass/animations.js +97 -0
  65. package/dist/sheets-of-glass/index.d.ts +3 -0
  66. package/dist/sheets-of-glass/index.d.ts.map +1 -0
  67. package/dist/sheets-of-glass/index.js +174 -0
  68. package/dist/sheets-of-glass/interfaces.d.ts +16 -0
  69. package/dist/sheets-of-glass/interfaces.d.ts.map +1 -0
  70. package/dist/sheets-of-glass/interfaces.js +1 -0
  71. package/dist/tab-bar-searchable/animations/enter.d.ts +8 -0
  72. package/dist/tab-bar-searchable/animations/enter.d.ts.map +1 -0
  73. package/dist/tab-bar-searchable/animations/enter.js +73 -0
  74. package/dist/tab-bar-searchable/animations/leave.d.ts +8 -0
  75. package/dist/tab-bar-searchable/animations/leave.d.ts.map +1 -0
  76. package/dist/tab-bar-searchable/animations/leave.js +66 -0
  77. package/dist/tab-bar-searchable/index.d.ts +4 -0
  78. package/dist/tab-bar-searchable/index.d.ts.map +1 -0
  79. package/dist/tab-bar-searchable/index.js +75 -0
  80. package/dist/tab-bar-searchable/interfaces.d.ts +41 -0
  81. package/dist/tab-bar-searchable/interfaces.d.ts.map +1 -0
  82. package/dist/tab-bar-searchable/interfaces.js +5 -0
  83. package/dist/tab-bar-searchable/utils.d.ts +12 -0
  84. package/dist/tab-bar-searchable/utils.d.ts.map +1 -0
  85. package/dist/tab-bar-searchable/utils.js +60 -0
  86. package/dist/transition/index.d.ts +19 -0
  87. package/dist/transition/index.d.ts.map +1 -0
  88. package/dist/transition/index.js +219 -0
  89. package/dist/transition/ios.transition.d.ts +5 -0
  90. package/dist/transition/ios.transition.d.ts.map +1 -0
  91. package/dist/transition/ios.transition.js +609 -0
  92. package/dist/utils.d.ts +17 -0
  93. package/dist/utils.d.ts.map +1 -0
  94. package/dist/utils.js +69 -0
  95. package/docs/e2e-testing.md +51 -0
  96. package/docs/eslint.md +73 -0
  97. package/docs/experimental-animation.md +85 -0
  98. package/docs/features.md +88 -0
  99. package/docs/feedback.md +65 -0
  100. package/docs/ios-18.md +16 -0
  101. package/docs/migration.md +94 -0
  102. package/docs/special-markup.md +145 -0
  103. package/docs/using-ion-item-group.md +47 -0
  104. package/package.json +63 -0
  105. package/src/focus-controller/index.ts +123 -0
  106. package/src/index.ts +33 -0
  107. package/src/popover/animations/ios.enter.ts +144 -0
  108. package/src/popover/animations/ios.leave.ts +76 -0
  109. package/src/popover/popover-interface.ts +44 -0
  110. package/src/popover/utils.ts +696 -0
  111. package/src/sheets-of-glass/animations.ts +120 -0
  112. package/src/sheets-of-glass/index.ts +214 -0
  113. package/src/sheets-of-glass/interfaces.ts +17 -0
  114. package/src/styles/components/ion-action-sheet.scss +85 -0
  115. package/src/styles/components/ion-alert.scss +66 -0
  116. package/src/styles/components/ion-button.scss +443 -0
  117. package/src/styles/components/ion-card.scss +7 -0
  118. package/src/styles/components/ion-content.scss +22 -0
  119. package/src/styles/components/ion-datetime.scss +9 -0
  120. package/src/styles/components/ion-fab.scss +104 -0
  121. package/src/styles/components/ion-inputs.scss +82 -0
  122. package/src/styles/components/ion-list.scss +44 -0
  123. package/src/styles/components/ion-loading.scss +11 -0
  124. package/src/styles/components/ion-menu.scss +110 -0
  125. package/src/styles/components/ion-modal.scss +42 -0
  126. package/src/styles/components/ion-picker.scss +4 -0
  127. package/src/styles/components/ion-popover.scss +33 -0
  128. package/src/styles/components/ion-range.scss +90 -0
  129. package/src/styles/components/ion-searchbar.scss +68 -0
  130. package/src/styles/components/ion-segment.scss +150 -0
  131. package/src/styles/components/ion-tabs.scss +118 -0
  132. package/src/styles/components/ion-toast.scss +35 -0
  133. package/src/styles/components/ion-toggle.scss +65 -0
  134. package/src/styles/components/ion-toolbar.scss +76 -0
  135. package/src/styles/default-variables.scss +38 -0
  136. package/src/styles/ionic-theme-ios26-dark-always.scss +6 -0
  137. package/src/styles/ionic-theme-ios26-dark-class.scss +6 -0
  138. package/src/styles/ionic-theme-ios26-dark-system.scss +8 -0
  139. package/src/styles/ionic-theme-ios26.scss +23 -0
  140. package/src/styles/md-ion-list-inset.scss +22 -0
  141. package/src/styles/md-remove-ios-class-effect.scss +14 -0
  142. package/src/styles/utils/api.scss +146 -0
  143. package/src/styles/utils/dark/ion-button.scss +58 -0
  144. package/src/styles/utils/dark/ion-fab.scss +18 -0
  145. package/src/styles/utils/dark/ion-segment.scss +12 -0
  146. package/src/styles/utils/dark/ion-tabs.scss +21 -0
  147. package/src/styles/utils/searchable.scss +0 -0
  148. package/src/styles/utils/structured-list.scss +170 -0
  149. package/src/styles/utils/theme-dark.scss +25 -0
  150. package/src/styles/utils/translucent.scss +95 -0
  151. package/src/tab-bar-searchable/animations/enter.ts +92 -0
  152. package/src/tab-bar-searchable/animations/leave.ts +89 -0
  153. package/src/tab-bar-searchable/index.ts +141 -0
  154. package/src/tab-bar-searchable/interfaces.ts +28 -0
  155. package/src/tab-bar-searchable/utils.ts +75 -0
  156. package/src/transition/index.ts +369 -0
  157. package/src/transition/ios.transition.ts +966 -0
  158. package/src/utils.ts +91 -0
@@ -0,0 +1,966 @@
1
+ import type { Animation } from '@ionic/core';
2
+ import { createAnimation } from '@ionic/core';
3
+ import type { TransitionOptions } from './index';
4
+ import { getIonPageElement } from './index';
5
+
6
+ const DURATION = 540;
7
+
8
+ // TODO(FW-2832): types
9
+
10
+ const getClonedElement = <T extends HTMLIonBackButtonElement | HTMLIonTitleElement>(tagName: string) => {
11
+ return document.querySelector<T>(`${tagName}.ion-cloned-element`);
12
+ };
13
+
14
+ export const shadow = <T extends Element>(el: T): ShadowRoot | T => {
15
+ return el.shadowRoot || el;
16
+ };
17
+
18
+ const animateFixedBackButton = (
19
+ root: Animation,
20
+ navEl: HTMLElement,
21
+ page: HTMLElement,
22
+ entering: boolean,
23
+ interactive: boolean,
24
+ otherPage?: HTMLElement,
25
+ ) => {
26
+ const button = page.querySelector<HTMLIonBackButtonElement>(
27
+ ':scope > ion-header.header-translucent:not(.ios26-disabled) ion-back-button:not(.ios26-disabled)',
28
+ );
29
+ if (!button || button.offsetWidth === 0) {
30
+ return;
31
+ }
32
+
33
+ const otherButton = otherPage?.querySelector<HTMLIonBackButtonElement>(
34
+ ':scope > ion-header.header-translucent:not(.ios26-disabled) ion-back-button:not(.ios26-disabled)',
35
+ );
36
+ const persistent = !!otherButton && otherButton.offsetWidth > 0;
37
+ const buttons = [button, ...(persistent ? [otherButton!] : [])].map((element) => ({
38
+ element,
39
+ visibility: element.style.visibility,
40
+ }));
41
+ const rect = button.getBoundingClientRect();
42
+ const width = button.offsetWidth;
43
+ const height = button.offsetHeight;
44
+ const clone = getClonedElement<HTMLIonBackButtonElement>('ion-back-button');
45
+ if (!clone) {
46
+ return;
47
+ }
48
+ const cloneParent = clone.parentNode!;
49
+ const cloneNextSibling = clone.nextSibling;
50
+ const cloneStyle = clone.getAttribute('style');
51
+ clone.icon = button.icon;
52
+ clone.text = button.text;
53
+ clone.mode = button.mode;
54
+ clone.color = button.color;
55
+ clone.disabled = button.disabled;
56
+ const icon = shadow(clone).querySelector('ion-icon');
57
+ const animation = createAnimation().addElement(clone);
58
+ const fadeStart = !entering && interactive ? 0.8 : 0.4;
59
+ const fadeEnd = entering ? 0.96 : interactive ? 1 : 0.95;
60
+ if (persistent) {
61
+ animation.fromTo('transform', 'scale(1)', 'scale(1)').fromTo('opacity', 1, 1);
62
+ } else if (entering) {
63
+ animation.keyframes([
64
+ { offset: 0, transform: 'scale(1.2)', opacity: 0 },
65
+ { offset: fadeStart, transform: 'scale(1.2)', opacity: 0 },
66
+ { offset: 0.65, transform: 'scale(1.12)', opacity: 0.15 },
67
+ { offset: 0.9, transform: 'scale(1.02)', opacity: 0.75 },
68
+ { offset: fadeEnd, transform: 'scale(1)', opacity: 1 },
69
+ { offset: 1, transform: 'scale(1)', opacity: 1 },
70
+ ]);
71
+ } else {
72
+ animation.keyframes([
73
+ { offset: 0, transform: 'scale(1)', opacity: 1 },
74
+ { offset: fadeStart, transform: 'scale(1)', opacity: 1 },
75
+ { offset: fadeEnd, transform: 'scale(1.2)', opacity: 0 },
76
+ { offset: 1, transform: 'scale(1.2)', opacity: 0 },
77
+ ]);
78
+ }
79
+ if (icon && !persistent) {
80
+ const from = entering ? 'blur(4px)' : 'blur(0px)';
81
+ const to = entering ? 'blur(0px)' : 'blur(4px)';
82
+ animation.addAnimation(
83
+ createAnimation()
84
+ .addElement(icon)
85
+ .keyframes([
86
+ { offset: 0, filter: from },
87
+ { offset: fadeStart, filter: from },
88
+ { offset: fadeEnd, filter: to },
89
+ { offset: 1, filter: to },
90
+ ]),
91
+ );
92
+ }
93
+ root.beforeAddWrite(() => {
94
+ Object.assign(clone.style, {
95
+ position: 'fixed',
96
+ left: `${rect.left + (rect.width - width) / 2}px`,
97
+ top: `${rect.top + (rect.height - height) / 2}px`,
98
+ width: `${width}px`,
99
+ height: `${height}px`,
100
+ margin: '0',
101
+ pointerEvents: 'none',
102
+ visibility: 'visible',
103
+ display: getComputedStyle(button).display,
104
+ zIndex: '1000',
105
+ });
106
+ navEl.appendChild(clone);
107
+ buttons.forEach(({ element }) => (element.style.visibility = 'hidden'));
108
+ });
109
+ root.afterAddWrite(() => {
110
+ buttons.forEach(({ element, visibility }) => (element.style.visibility = visibility));
111
+ cloneParent.insertBefore(clone, cloneNextSibling);
112
+ if (cloneStyle === null) {
113
+ clone.removeAttribute('style');
114
+ } else {
115
+ clone.setAttribute('style', cloneStyle);
116
+ }
117
+ });
118
+ root.addAnimation(animation);
119
+ };
120
+
121
+ const getLargeTitle = (refEl: any) => {
122
+ const tabs = refEl.tagName === 'ION-TABS' ? refEl : refEl.querySelector('ion-tabs');
123
+ const query = 'ion-content ion-header:not(.header-collapse-condense-inactive) ion-title.title-large';
124
+
125
+ if (tabs != null) {
126
+ const activeTab = tabs.querySelector('ion-tab:not(.tab-hidden), .ion-page:not(.ion-page-hidden)');
127
+ return activeTab != null ? activeTab.querySelector(query) : null;
128
+ }
129
+
130
+ return refEl.querySelector(query);
131
+ };
132
+
133
+ const getBackButton = (refEl: any, backDirection: boolean) => {
134
+ const tabs = refEl.tagName === 'ION-TABS' ? refEl : refEl.querySelector('ion-tabs');
135
+ let buttonsList = [];
136
+
137
+ if (tabs != null) {
138
+ const activeTab = tabs.querySelector('ion-tab:not(.tab-hidden), .ion-page:not(.ion-page-hidden)');
139
+ if (activeTab != null) {
140
+ buttonsList = activeTab.querySelectorAll('ion-buttons');
141
+ }
142
+ } else {
143
+ buttonsList = refEl.querySelectorAll('ion-buttons');
144
+ }
145
+
146
+ for (const buttons of buttonsList) {
147
+ const parentHeader = buttons.closest('ion-header');
148
+ const activeHeader = parentHeader && !parentHeader.classList.contains('header-collapse-condense-inactive');
149
+ const backButton = buttons.querySelector('ion-back-button');
150
+ const buttonsCollapse = buttons.classList.contains('buttons-collapse');
151
+ const startSlot = buttons.slot === 'start' || buttons.slot === '';
152
+
153
+ if (backButton !== null && startSlot && ((buttonsCollapse && activeHeader && backDirection) || !buttonsCollapse)) {
154
+ return backButton;
155
+ }
156
+ }
157
+
158
+ return null;
159
+ };
160
+
161
+ const createLargeTitleTransition = (
162
+ rootAnimation: Animation,
163
+ rtl: boolean,
164
+ backDirection: boolean,
165
+ enteringEl: HTMLElement,
166
+ leavingEl: HTMLElement | undefined,
167
+ ) => {
168
+ const enteringBackButton = getBackButton(enteringEl, backDirection);
169
+ const leavingLargeTitle = getLargeTitle(leavingEl);
170
+
171
+ const enteringLargeTitle = getLargeTitle(enteringEl);
172
+ const leavingBackButton = getBackButton(leavingEl, backDirection);
173
+
174
+ const shouldAnimationForward = enteringBackButton !== null && leavingLargeTitle !== null && !backDirection;
175
+ const shouldAnimationBackward = enteringLargeTitle !== null && leavingBackButton !== null && backDirection;
176
+
177
+ if (shouldAnimationForward) {
178
+ const leavingLargeTitleBox = leavingLargeTitle.getBoundingClientRect();
179
+ const enteringBackButtonBox = enteringBackButton.getBoundingClientRect();
180
+
181
+ const enteringBackButtonTextEl = shadow(enteringBackButton).querySelector('.button-text');
182
+
183
+ // Text element not rendered if developers pass text="" to the back button
184
+ const enteringBackButtonTextBox = enteringBackButtonTextEl?.getBoundingClientRect();
185
+
186
+ const leavingLargeTitleTextEl = shadow(leavingLargeTitle).querySelector('.toolbar-title')!;
187
+ const leavingLargeTitleTextBox = leavingLargeTitleTextEl.getBoundingClientRect();
188
+
189
+ animateLargeTitle(
190
+ rootAnimation,
191
+ rtl,
192
+ backDirection,
193
+ leavingLargeTitle,
194
+ leavingLargeTitleBox,
195
+ leavingLargeTitleTextBox,
196
+ enteringBackButtonBox,
197
+ enteringBackButtonTextEl,
198
+ enteringBackButtonTextBox,
199
+ );
200
+ // animateBackButton(
201
+ // rootAnimation,
202
+ // rtl,
203
+ // backDirection,
204
+ // enteringBackButton,
205
+ // enteringBackButtonBox,
206
+ // enteringBackButtonTextEl,
207
+ // enteringBackButtonTextBox,
208
+ // leavingLargeTitle,
209
+ // leavingLargeTitleTextBox,
210
+ // );
211
+ } else if (shouldAnimationBackward) {
212
+ const enteringLargeTitleBox = enteringLargeTitle.getBoundingClientRect();
213
+ const leavingBackButtonBox = leavingBackButton.getBoundingClientRect();
214
+
215
+ const leavingBackButtonTextEl = shadow(leavingBackButton).querySelector('.button-text');
216
+
217
+ // Text element not rendered if developers pass text="" to the back button
218
+ const leavingBackButtonTextBox = leavingBackButtonTextEl?.getBoundingClientRect();
219
+
220
+ const enteringLargeTitleTextEl = shadow(enteringLargeTitle).querySelector('.toolbar-title')!;
221
+ const enteringLargeTitleTextBox = enteringLargeTitleTextEl.getBoundingClientRect();
222
+
223
+ animateLargeTitle(
224
+ rootAnimation,
225
+ rtl,
226
+ backDirection,
227
+ enteringLargeTitle,
228
+ enteringLargeTitleBox,
229
+ enteringLargeTitleTextBox,
230
+ leavingBackButtonBox,
231
+ leavingBackButtonTextEl,
232
+ leavingBackButtonTextBox,
233
+ );
234
+ // animateBackButton(
235
+ // rootAnimation,
236
+ // rtl,
237
+ // backDirection,
238
+ // leavingBackButton,
239
+ // leavingBackButtonBox,
240
+ // leavingBackButtonTextEl,
241
+ // leavingBackButtonTextBox,
242
+ // enteringLargeTitle,
243
+ // enteringLargeTitleTextBox,
244
+ // );
245
+ }
246
+
247
+ return {
248
+ forward: shouldAnimationForward,
249
+ backward: shouldAnimationBackward,
250
+ };
251
+ };
252
+
253
+ const animateBackButton = (
254
+ rootAnimation: Animation,
255
+ rtl: boolean,
256
+ backDirection: boolean,
257
+ backButtonEl: HTMLIonBackButtonElement,
258
+ backButtonBox: DOMRect,
259
+ backButtonTextEl: HTMLElement | null,
260
+ backButtonTextBox: DOMRect | undefined,
261
+ largeTitleEl: HTMLIonTitleElement,
262
+ largeTitleTextBox: DOMRect,
263
+ ) => {
264
+ const BACK_BUTTON_START_OFFSET = rtl ? `calc(100% - ${backButtonBox.right + 4}px)` : `${backButtonBox.left - 4}px`;
265
+
266
+ const TEXT_ORIGIN_X = rtl ? 'right' : 'left';
267
+ const ICON_ORIGIN_X = rtl ? 'left' : 'right';
268
+
269
+ const CONTAINER_ORIGIN_X = rtl ? 'right' : 'left';
270
+ let WIDTH_SCALE = 1;
271
+ let HEIGHT_SCALE = 1;
272
+
273
+ let TEXT_START_SCALE = `scale(${HEIGHT_SCALE})`;
274
+ const TEXT_END_SCALE = 'scale(1)';
275
+
276
+ if (backButtonTextEl && backButtonTextBox) {
277
+ /**
278
+ * When the title and back button texts match then they should overlap during the
279
+ * page transition. If the texts do not match up then the back button text scale
280
+ * adjusts to not perfectly match the large title text otherwise the proportions
281
+ * will be incorrect. When the texts match we scale both the width and height to
282
+ * account for font weight differences between the title and back button.
283
+ */
284
+ const doTitleAndButtonTextsMatch = backButtonTextEl.textContent?.trim() === largeTitleEl.textContent?.trim();
285
+ WIDTH_SCALE = largeTitleTextBox.width / backButtonTextBox.width;
286
+ /**
287
+ * Subtract an offset to account for slight sizing/padding differences between the
288
+ * title and the back button.
289
+ */
290
+ HEIGHT_SCALE = (largeTitleTextBox.height - LARGE_TITLE_SIZE_OFFSET) / backButtonTextBox.height;
291
+
292
+ /**
293
+ * Even though we set TEXT_START_SCALE to HEIGHT_SCALE above, we potentially need
294
+ * to re-compute this here since the HEIGHT_SCALE may have changed.
295
+ */
296
+ TEXT_START_SCALE = doTitleAndButtonTextsMatch ? `scale(${WIDTH_SCALE}, ${HEIGHT_SCALE})` : `scale(${HEIGHT_SCALE})`;
297
+ }
298
+
299
+ const backButtonIconEl = shadow(backButtonEl).querySelector('ion-icon')!;
300
+ const backButtonIconBox = backButtonIconEl.getBoundingClientRect();
301
+
302
+ /**
303
+ * We need to offset the container by the icon dimensions
304
+ * so that the back button text aligns with the large title
305
+ * text. Otherwise, the back button icon will align with the
306
+ * large title text but the back button text will not.
307
+ */
308
+ const CONTAINER_START_TRANSLATE_X = rtl
309
+ ? `${backButtonIconBox.width / 2 - (backButtonIconBox.right - backButtonBox.right)}px`
310
+ : `${backButtonBox.left - backButtonIconBox.width / 2}px`;
311
+ const CONTAINER_END_TRANSLATE_X = rtl ? `-${window.innerWidth - backButtonBox.right}px` : `${backButtonBox.left}px`;
312
+
313
+ /**
314
+ * Back button container should be
315
+ * aligned to the top of the title container
316
+ * so the texts overlap as the back button
317
+ * text begins to fade in.
318
+ */
319
+ const CONTAINER_START_TRANSLATE_Y = `${largeTitleTextBox.top}px`;
320
+
321
+ /**
322
+ * The cloned back button should align exactly with the
323
+ * real back button on the entering page otherwise there will
324
+ * be a layout shift.
325
+ */
326
+ const CONTAINER_END_TRANSLATE_Y = `${backButtonBox.top}px`;
327
+
328
+ /**
329
+ * In the forward direction, the cloned back button
330
+ * container should translate from over the large title
331
+ * to over the back button. In the backward direction,
332
+ * it should translate from over the back button to over
333
+ * the large title.
334
+ */
335
+ const FORWARD_CONTAINER_KEYFRAMES = [
336
+ { offset: 0, transform: `translate3d(${CONTAINER_START_TRANSLATE_X}, ${CONTAINER_START_TRANSLATE_Y}, 0)` },
337
+ { offset: 1, transform: `translate3d(${CONTAINER_END_TRANSLATE_X}, ${CONTAINER_END_TRANSLATE_Y}, 0)` },
338
+ ];
339
+ const BACKWARD_CONTAINER_KEYFRAMES = [
340
+ { offset: 0, transform: `translate3d(${CONTAINER_END_TRANSLATE_X}, ${CONTAINER_END_TRANSLATE_Y}, 0)` },
341
+ { offset: 1, transform: `translate3d(${CONTAINER_START_TRANSLATE_X}, ${CONTAINER_START_TRANSLATE_Y}, 0)` },
342
+ ];
343
+ const CONTAINER_KEYFRAMES = backDirection ? BACKWARD_CONTAINER_KEYFRAMES : FORWARD_CONTAINER_KEYFRAMES;
344
+
345
+ /**
346
+ * In the forward direction, the text in the cloned back button
347
+ * should start to be (roughly) the size of the large title
348
+ * and then scale down to be the size of the actual back button.
349
+ * The text should also translate, but that translate is handled
350
+ * by the container keyframes.
351
+ */
352
+ const FORWARD_TEXT_KEYFRAMES = [
353
+ { offset: 0, opacity: 0, transform: TEXT_START_SCALE },
354
+ { offset: 1, opacity: 1, transform: TEXT_END_SCALE },
355
+ ];
356
+ const BACKWARD_TEXT_KEYFRAMES = [
357
+ { offset: 0, opacity: 1, transform: TEXT_END_SCALE },
358
+ { offset: 1, opacity: 0, transform: TEXT_START_SCALE },
359
+ ];
360
+ const TEXT_KEYFRAMES = backDirection ? BACKWARD_TEXT_KEYFRAMES : FORWARD_TEXT_KEYFRAMES;
361
+
362
+ /**
363
+ * The icon should scale in/out in the second
364
+ * half of the animation. The icon should also
365
+ * translate, but that translate is handled by the
366
+ * container keyframes.
367
+ */
368
+ const FORWARD_ICON_KEYFRAMES = [
369
+ { offset: 0, opacity: 0, transform: 'scale(0.6)' },
370
+ { offset: 0.6, opacity: 0, transform: 'scale(0.6)' },
371
+ { offset: 1, opacity: 1, transform: 'scale(1)' },
372
+ ];
373
+ const BACKWARD_ICON_KEYFRAMES = [
374
+ { offset: 0, opacity: 1, transform: 'scale(1)' },
375
+ { offset: 0.2, opacity: 0, transform: 'scale(0.6)' },
376
+ { offset: 1, opacity: 0, transform: 'scale(0.6)' },
377
+ ];
378
+ const ICON_KEYFRAMES = backDirection ? BACKWARD_ICON_KEYFRAMES : FORWARD_ICON_KEYFRAMES;
379
+
380
+ const enteringBackButtonTextAnimation = createAnimation();
381
+ const enteringBackButtonIconAnimation = createAnimation();
382
+ const enteringBackButtonAnimation = createAnimation();
383
+
384
+ const clonedBackButtonEl = getClonedElement<HTMLIonBackButtonElement>('ion-back-button')!;
385
+
386
+ const clonedBackButtonTextEl = shadow(clonedBackButtonEl).querySelector('.button-text')!;
387
+ const clonedBackButtonIconEl = shadow(clonedBackButtonEl).querySelector('ion-icon')!;
388
+
389
+ clonedBackButtonEl.text = backButtonEl.text;
390
+ clonedBackButtonEl.mode = backButtonEl.mode;
391
+ clonedBackButtonEl.icon = backButtonEl.icon;
392
+ clonedBackButtonEl.color = backButtonEl.color;
393
+ clonedBackButtonEl.disabled = backButtonEl.disabled;
394
+
395
+ clonedBackButtonEl.style.setProperty('display', 'block');
396
+ clonedBackButtonEl.style.setProperty('position', 'fixed');
397
+
398
+ enteringBackButtonIconAnimation.addElement(clonedBackButtonIconEl);
399
+ enteringBackButtonTextAnimation.addElement(clonedBackButtonTextEl);
400
+ enteringBackButtonAnimation.addElement(clonedBackButtonEl);
401
+
402
+ enteringBackButtonAnimation
403
+ .beforeStyles({
404
+ position: 'absolute',
405
+ top: '0px',
406
+ [CONTAINER_ORIGIN_X]: '0px',
407
+ })
408
+ /**
409
+ * The write hooks must be set on this animation as it is guaranteed to run. Other
410
+ * animations such as the back button text animation will not run if the back button
411
+ * has no visible text.
412
+ */
413
+ .beforeAddWrite(() => {
414
+ backButtonEl.style.setProperty('display', 'none');
415
+ clonedBackButtonEl.style.setProperty(TEXT_ORIGIN_X, BACK_BUTTON_START_OFFSET);
416
+ })
417
+ .afterAddWrite(() => {
418
+ backButtonEl.style.setProperty('display', '');
419
+ clonedBackButtonEl.style.setProperty('display', 'none');
420
+ clonedBackButtonEl.style.removeProperty(TEXT_ORIGIN_X);
421
+ })
422
+ .keyframes(CONTAINER_KEYFRAMES);
423
+
424
+ enteringBackButtonTextAnimation
425
+ .beforeStyles({
426
+ 'transform-origin': `${TEXT_ORIGIN_X} top`,
427
+ })
428
+ .keyframes(TEXT_KEYFRAMES);
429
+
430
+ enteringBackButtonIconAnimation
431
+ .beforeStyles({
432
+ 'transform-origin': `${ICON_ORIGIN_X} center`,
433
+ })
434
+ .keyframes(ICON_KEYFRAMES);
435
+
436
+ rootAnimation.addAnimation([enteringBackButtonTextAnimation, enteringBackButtonIconAnimation, enteringBackButtonAnimation]);
437
+ };
438
+
439
+ const animateLargeTitle = (
440
+ rootAnimation: Animation,
441
+ rtl: boolean,
442
+ backDirection: boolean,
443
+ largeTitleEl: HTMLIonTitleElement,
444
+ largeTitleBox: DOMRect,
445
+ largeTitleTextBox: DOMRect,
446
+ backButtonBox: DOMRect,
447
+ backButtonTextEl: HTMLElement | null,
448
+ backButtonTextBox: DOMRect | undefined,
449
+ ) => {
450
+ /**
451
+ * The horizontal transform origin for the large title
452
+ */
453
+ const ORIGIN_X = rtl ? 'right' : 'left';
454
+
455
+ const TITLE_START_OFFSET = rtl ? `calc(100% - ${largeTitleBox.right}px)` : `${largeTitleBox.left}px`;
456
+
457
+ /**
458
+ * The cloned large should align exactly with the
459
+ * real large title on the leaving page otherwise there will
460
+ * be a layout shift.
461
+ */
462
+ const START_TRANSLATE_X = '0px';
463
+ const START_TRANSLATE_Y = `${largeTitleBox.top}px`;
464
+
465
+ /**
466
+ * How much to offset the large title translation by.
467
+ * This accounts for differences in sizing between the large
468
+ * title and the back button due to padding and font weight.
469
+ */
470
+ const LARGE_TITLE_TRANSLATION_OFFSET = 8;
471
+ let END_TRANSLATE_X = rtl
472
+ ? `-${window.innerWidth - backButtonBox.right - LARGE_TITLE_TRANSLATION_OFFSET}px`
473
+ : `${backButtonBox.x + LARGE_TITLE_TRANSLATION_OFFSET}px`;
474
+
475
+ /**
476
+ * How much to scale the large title up/down by.
477
+ */
478
+ let HEIGHT_SCALE = 0.5;
479
+
480
+ /**
481
+ * The large title always starts full size.
482
+ */
483
+ const START_SCALE = 'scale(1)';
484
+
485
+ /**
486
+ * By default, we don't worry about having the large title scaled to perfectly
487
+ * match the back button because we don't know if the back button's text matches
488
+ * the large title's text.
489
+ */
490
+ let END_SCALE = `scale(${HEIGHT_SCALE})`;
491
+
492
+ // Text element not rendered if developers pass text="" to the back button
493
+ if (backButtonTextEl && backButtonTextBox) {
494
+ /**
495
+ * The scaled title should (roughly) overlap the back button. This ensures that
496
+ * the back button and title overlap during the animation. Note that since both
497
+ * elements either fade in or fade out over the course of the animation, neither
498
+ * element will be fully visible on top of the other. As a result, the overlap
499
+ * does not need to be perfect, so approximate values are acceptable here.
500
+ */
501
+ END_TRANSLATE_X = rtl
502
+ ? `-${window.innerWidth - backButtonTextBox.right - LARGE_TITLE_TRANSLATION_OFFSET}px`
503
+ : `${backButtonTextBox.x - LARGE_TITLE_TRANSLATION_OFFSET}px`;
504
+
505
+ /**
506
+ * In the forward direction, the large title should start at its normal size and
507
+ * then scale down to be (roughly) the size of the back button on the other view.
508
+ * In the backward direction, the large title should start at (roughly) the size
509
+ * of the back button and then scale up to its original size.
510
+ * Note that since both elements either fade in or fade out over the course of the
511
+ * animation, neither element will be fully visible on top of the other. As a result,
512
+ * the overlap does not need to be perfect, so approximate values are acceptable here.
513
+ */
514
+
515
+ /**
516
+ * When the title and back button texts match then they should overlap during the
517
+ * page transition. If the texts do not match up then the large title text scale
518
+ * adjusts to not perfectly match the back button text otherwise the proportions
519
+ * will be incorrect. When the texts match we scale both the width and height to
520
+ * account for font weight differences between the title and back button.
521
+ */
522
+ const doTitleAndButtonTextsMatch = backButtonTextEl.textContent?.trim() === largeTitleEl.textContent?.trim();
523
+
524
+ const WIDTH_SCALE = backButtonTextBox.width / largeTitleTextBox.width;
525
+ HEIGHT_SCALE = backButtonTextBox.height / (largeTitleTextBox.height - LARGE_TITLE_SIZE_OFFSET);
526
+
527
+ /**
528
+ * Even though we set TEXT_START_SCALE to HEIGHT_SCALE above, we potentially need
529
+ * to re-compute this here since the HEIGHT_SCALE may have changed.
530
+ */
531
+ END_SCALE = doTitleAndButtonTextsMatch ? `scale(${WIDTH_SCALE}, ${HEIGHT_SCALE})` : `scale(${HEIGHT_SCALE})`;
532
+ }
533
+
534
+ /**
535
+ * The midpoints of the back button and the title should align such that the back
536
+ * button and title appear to be centered with each other.
537
+ */
538
+ const backButtonMidPoint = backButtonBox.top + backButtonBox.height / 2;
539
+ const titleMidPoint = (largeTitleBox.height * HEIGHT_SCALE) / 2;
540
+ const END_TRANSLATE_Y = `${backButtonMidPoint - titleMidPoint}px`;
541
+
542
+ const BACKWARDS_KEYFRAMES = [
543
+ { offset: 0, opacity: 0, transform: `translate3d(${END_TRANSLATE_X}, ${END_TRANSLATE_Y}, 0) ${END_SCALE}` },
544
+ { offset: 0.1, opacity: 0 },
545
+ { offset: 1, opacity: 1, transform: `translate3d(${START_TRANSLATE_X}, ${START_TRANSLATE_Y}, 0) ${START_SCALE}` },
546
+ ];
547
+ const FORWARDS_KEYFRAMES = [
548
+ {
549
+ offset: 0,
550
+ opacity: 0.99,
551
+ transform: `translate3d(${START_TRANSLATE_X}, ${START_TRANSLATE_Y}, 0) ${START_SCALE}`,
552
+ },
553
+ { offset: 0.6, opacity: 0 },
554
+ { offset: 1, opacity: 0, transform: `translate3d(${END_TRANSLATE_X}, ${END_TRANSLATE_Y}, 0) ${END_SCALE}` },
555
+ ];
556
+
557
+ const KEYFRAMES = backDirection ? BACKWARDS_KEYFRAMES : FORWARDS_KEYFRAMES;
558
+
559
+ const clonedTitleEl = getClonedElement<HTMLIonTitleElement>('ion-title')!;
560
+ const clonedLargeTitleAnimation = createAnimation();
561
+
562
+ clonedTitleEl.innerText = largeTitleEl.innerText;
563
+ clonedTitleEl.size = largeTitleEl.size;
564
+ clonedTitleEl.color = largeTitleEl.color;
565
+
566
+ clonedLargeTitleAnimation.addElement(clonedTitleEl);
567
+
568
+ clonedLargeTitleAnimation
569
+ .beforeStyles({
570
+ 'transform-origin': `${ORIGIN_X} top`,
571
+
572
+ /**
573
+ * Since font size changes will cause
574
+ * the dimension of the large title to change
575
+ * we need to set the cloned title height
576
+ * equal to that of the original large title height.
577
+ */
578
+ height: `${largeTitleBox.height}px`,
579
+ display: '',
580
+ position: 'relative',
581
+ [ORIGIN_X]: TITLE_START_OFFSET,
582
+ })
583
+ .beforeAddWrite(() => {
584
+ largeTitleEl.style.setProperty('opacity', '0');
585
+ })
586
+ .afterAddWrite(() => {
587
+ largeTitleEl.style.setProperty('opacity', '');
588
+ clonedTitleEl.style.setProperty('display', 'none');
589
+ })
590
+ .keyframes(KEYFRAMES);
591
+
592
+ rootAnimation.addAnimation(clonedLargeTitleAnimation);
593
+ };
594
+
595
+ export const iosTransitionAnimation = (navEl: HTMLElement, opts: TransitionOptions): Animation => {
596
+ try {
597
+ const EASING = 'cubic-bezier(0.32,0.72,0,1)';
598
+ const OPACITY = 'opacity';
599
+ const TRANSFORM = 'transform';
600
+ const CENTER = '0%';
601
+ const OFF_OPACITY = 0.8;
602
+
603
+ const isRTL = navEl.ownerDocument.dir === 'rtl';
604
+ const OFF_RIGHT = isRTL ? '-99.5%' : '99.5%';
605
+ const OFF_LEFT = isRTL ? '33%' : '-33%';
606
+
607
+ const enteringEl = opts.enteringEl;
608
+ const leavingEl = opts.leavingEl;
609
+
610
+ const backDirection = opts.direction === 'back';
611
+ const contentEl = enteringEl.querySelector(':scope > ion-content');
612
+ const headerEls = enteringEl.querySelectorAll(':scope > ion-header > *:not(ion-toolbar), :scope > ion-footer > *');
613
+ const enteringToolBarEls = enteringEl.querySelectorAll(':scope > ion-header > ion-toolbar');
614
+
615
+ const rootAnimation = createAnimation();
616
+ const enteringContentAnimation = createAnimation();
617
+
618
+ rootAnimation
619
+ .addElement(enteringEl)
620
+ .duration((opts.duration ?? 0) || DURATION)
621
+ .easing(opts.easing || EASING)
622
+ .fill('both')
623
+ .beforeRemoveClass('ion-page-invisible');
624
+
625
+ const topPage = backDirection ? leavingEl : enteringEl;
626
+ if (topPage?.querySelector(':scope > ion-header.header-translucent:not(.ios26-disabled)')) {
627
+ const shadow = topPage.style.boxShadow;
628
+ rootAnimation.beforeAddWrite(() => {
629
+ topPage.style.boxShadow = `${isRTL ? 4 : -4}px 0 24px rgba(0, 0, 0, 0.04)`;
630
+ });
631
+ rootAnimation.afterAddWrite(() => {
632
+ topPage.style.boxShadow = shadow;
633
+ });
634
+ }
635
+
636
+ // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
637
+ if (leavingEl && navEl !== null && navEl !== undefined) {
638
+ const navDecorAnimation = createAnimation();
639
+ navDecorAnimation.addElement(navEl);
640
+ rootAnimation.addAnimation(navDecorAnimation);
641
+ }
642
+
643
+ if (enteringEl.querySelector(':scope > ion-header.header-translucent:not(.ios26-disabled)')) {
644
+ enteringContentAnimation.addElement(enteringEl);
645
+ } else if (!contentEl && enteringToolBarEls.length === 0 && headerEls.length === 0) {
646
+ enteringContentAnimation.addElement(enteringEl.querySelector(':scope > .ion-page, :scope > ion-nav, :scope > ion-tabs')!); // REVIEW
647
+ } else {
648
+ enteringContentAnimation.addElement(contentEl!); // REVIEW
649
+ enteringContentAnimation.addElement(headerEls);
650
+ }
651
+
652
+ rootAnimation.addAnimation(enteringContentAnimation);
653
+
654
+ if (backDirection) {
655
+ enteringContentAnimation
656
+ .beforeClearStyles([OPACITY])
657
+ .fromTo('transform', `translateX(${OFF_LEFT})`, `translateX(${CENTER})`)
658
+ .fromTo(OPACITY, OFF_OPACITY, 1);
659
+ } else {
660
+ // entering content, forward direction
661
+ enteringContentAnimation.beforeClearStyles([OPACITY]).fromTo('transform', `translateX(${OFF_RIGHT})`, `translateX(${CENTER})`);
662
+ }
663
+
664
+ if (contentEl && !enteringEl.querySelector(':scope > ion-header.header-translucent:not(.ios26-disabled)')) {
665
+ const enteringTransitionEffectEl = shadow(contentEl).querySelector('.transition-effect');
666
+ if (enteringTransitionEffectEl) {
667
+ const enteringTransitionCoverEl = enteringTransitionEffectEl.querySelector('.transition-cover');
668
+ const enteringTransitionShadowEl = enteringTransitionEffectEl.querySelector('.transition-shadow');
669
+
670
+ const enteringTransitionEffect = createAnimation();
671
+ const enteringTransitionCover = createAnimation();
672
+ const enteringTransitionShadow = createAnimation();
673
+
674
+ enteringTransitionEffect
675
+ .addElement(enteringTransitionEffectEl)
676
+ .beforeStyles({ opacity: '1', display: 'block' })
677
+ .afterStyles({ opacity: '', display: '' });
678
+
679
+ enteringTransitionCover
680
+ .addElement(enteringTransitionCoverEl!) // REVIEW
681
+ .beforeClearStyles([OPACITY])
682
+ .fromTo(OPACITY, 0, 0.1);
683
+
684
+ enteringTransitionShadow
685
+ .addElement(enteringTransitionShadowEl!) // REVIEW
686
+ .beforeClearStyles([OPACITY])
687
+ .fromTo(OPACITY, 0.03, 0.7);
688
+
689
+ enteringTransitionEffect.addAnimation([enteringTransitionCover, enteringTransitionShadow]);
690
+ enteringContentAnimation.addAnimation([enteringTransitionEffect]);
691
+ }
692
+ }
693
+
694
+ if (topPage) {
695
+ animateFixedBackButton(
696
+ rootAnimation,
697
+ navEl,
698
+ topPage,
699
+ !backDirection,
700
+ opts.progressCallback !== undefined,
701
+ backDirection ? enteringEl : leavingEl,
702
+ );
703
+ }
704
+
705
+ const enteringContentHasLargeTitle = enteringEl.querySelector('ion-header.header-collapse-condense');
706
+
707
+ enteringToolBarEls.forEach((enteringToolBarEl) => {
708
+ if (enteringToolBarEl.closest('ion-header')?.matches('.header-translucent:not(.ios26-disabled)')) {
709
+ return;
710
+ }
711
+ const enteringToolBar = createAnimation();
712
+ enteringToolBar.addElement(enteringToolBarEl);
713
+ rootAnimation.addAnimation(enteringToolBar);
714
+
715
+ const enteringTitle = createAnimation();
716
+ enteringTitle.addElement(enteringToolBarEl.querySelector('ion-title')!); // REVIEW
717
+
718
+ const enteringToolBarButtons = createAnimation();
719
+ const buttons = Array.from(enteringToolBarEl.querySelectorAll('ion-buttons,[menuToggle]'));
720
+
721
+ const parentHeader = enteringToolBarEl.closest('ion-header');
722
+ const inactiveHeader = parentHeader?.classList.contains('header-collapse-condense-inactive');
723
+
724
+ let buttonsToAnimate;
725
+ if (backDirection) {
726
+ buttonsToAnimate = buttons.filter((button) => {
727
+ const isCollapseButton = button.classList.contains('buttons-collapse');
728
+ return (isCollapseButton && !inactiveHeader) || !isCollapseButton;
729
+ });
730
+ } else {
731
+ buttonsToAnimate = buttons.filter((button) => !button.classList.contains('buttons-collapse'));
732
+ }
733
+
734
+ enteringToolBarButtons.addElement(buttonsToAnimate);
735
+
736
+ const enteringToolBarItems = createAnimation();
737
+ enteringToolBarItems.addElement(enteringToolBarEl.querySelectorAll(':scope > *:not(ion-title):not(ion-buttons):not([menuToggle])'));
738
+
739
+ const enteringToolBarBg = createAnimation();
740
+ enteringToolBarBg.addElement(shadow(enteringToolBarEl).querySelector('.toolbar-background')!); // REVIEW
741
+
742
+ const enteringBackButton = createAnimation();
743
+ const backButtonEl = enteringToolBarEl.querySelector('ion-back-button');
744
+
745
+ if (backButtonEl) {
746
+ enteringBackButton.addElement(backButtonEl);
747
+ }
748
+
749
+ enteringToolBar.addAnimation([enteringTitle, enteringToolBarButtons, enteringToolBarItems, enteringToolBarBg, enteringBackButton]);
750
+ enteringToolBarButtons.fromTo(OPACITY, 0.01, 1);
751
+ enteringToolBarItems.fromTo(OPACITY, 0.01, 1);
752
+
753
+ if (backDirection) {
754
+ if (!inactiveHeader) {
755
+ enteringTitle.fromTo('transform', `translateX(${OFF_LEFT})`, `translateX(${CENTER})`).fromTo(OPACITY, 0.01, 1);
756
+ }
757
+
758
+ enteringToolBarItems.fromTo('transform', `translateX(${OFF_LEFT})`, `translateX(${CENTER})`);
759
+
760
+ // back direction, entering page has a back button
761
+ enteringBackButton.fromTo(OPACITY, 0.01, 1);
762
+ } else {
763
+ // entering toolbar, forward direction
764
+ if (!enteringContentHasLargeTitle) {
765
+ enteringTitle.fromTo('transform', `translateX(${OFF_RIGHT})`, `translateX(${CENTER})`).fromTo(OPACITY, 0.01, 1);
766
+ }
767
+
768
+ enteringToolBarItems.fromTo('transform', `translateX(${OFF_RIGHT})`, `translateX(${CENTER})`);
769
+ enteringToolBarBg.beforeClearStyles([OPACITY, 'transform']);
770
+
771
+ const translucentHeader = parentHeader?.translucent;
772
+ if (!translucentHeader) {
773
+ enteringToolBarBg.fromTo(OPACITY, 0.01, 'var(--opacity)');
774
+ } else {
775
+ enteringToolBarBg.fromTo('transform', isRTL ? 'translateX(-100%)' : 'translateX(100%)', 'translateX(0px)');
776
+ }
777
+
778
+ // forward direction, entering page has a back button
779
+ enteringBackButton.fromTo(OPACITY, 0.01, 1);
780
+
781
+ if (backButtonEl) {
782
+ const enteringBackBtnText = createAnimation();
783
+ enteringBackBtnText
784
+ .addElement(shadow(backButtonEl).querySelector('.button-text')!) // REVIEW
785
+ .fromTo(`transform`, isRTL ? 'translateX(-100px)' : 'translateX(100px)', 'translateX(0px)');
786
+
787
+ enteringToolBar.addAnimation(enteringBackBtnText);
788
+ }
789
+ }
790
+ });
791
+
792
+ // setup leaving view
793
+ if (leavingEl) {
794
+ const leavingContent = createAnimation();
795
+ const leavingContentEl = leavingEl.querySelector(':scope > ion-content');
796
+ const leavingToolBarEls = leavingEl.querySelectorAll(':scope > ion-header > ion-toolbar');
797
+ const leavingHeaderEls = leavingEl.querySelectorAll(':scope > ion-header > *:not(ion-toolbar), :scope > ion-footer > *');
798
+
799
+ if (leavingEl.querySelector(':scope > ion-header.header-translucent:not(.ios26-disabled)')) {
800
+ leavingContent.addElement(leavingEl);
801
+ } else if (!leavingContentEl && leavingToolBarEls.length === 0 && leavingHeaderEls.length === 0) {
802
+ leavingContent.addElement(leavingEl.querySelector(':scope > .ion-page, :scope > ion-nav, :scope > ion-tabs')!); // REVIEW
803
+ } else {
804
+ leavingContent.addElement(leavingContentEl!); // REVIEW
805
+ leavingContent.addElement(leavingHeaderEls);
806
+ }
807
+
808
+ rootAnimation.addAnimation(leavingContent);
809
+
810
+ if (backDirection) {
811
+ // leaving content, back direction
812
+ leavingContent
813
+ .beforeClearStyles([OPACITY])
814
+ .fromTo('transform', `translateX(${CENTER})`, isRTL ? 'translateX(-100%)' : 'translateX(100%)');
815
+
816
+ const leavingPage = getIonPageElement(leavingEl) as HTMLElement;
817
+ rootAnimation.afterAddWrite(() => {
818
+ if (rootAnimation.getDirection() === 'normal') {
819
+ leavingPage.style.setProperty('display', 'none');
820
+ }
821
+ });
822
+ } else {
823
+ // leaving content, forward direction
824
+ leavingContent.fromTo('transform', `translateX(${CENTER})`, `translateX(${OFF_LEFT})`).fromTo(OPACITY, 1, OFF_OPACITY);
825
+ }
826
+
827
+ if (leavingContentEl && !leavingEl.querySelector(':scope > ion-header.header-translucent:not(.ios26-disabled)')) {
828
+ const leavingTransitionEffectEl = shadow(leavingContentEl).querySelector('.transition-effect');
829
+
830
+ if (leavingTransitionEffectEl) {
831
+ const leavingTransitionCoverEl = leavingTransitionEffectEl.querySelector('.transition-cover');
832
+ const leavingTransitionShadowEl = leavingTransitionEffectEl.querySelector('.transition-shadow');
833
+
834
+ const leavingTransitionEffect = createAnimation();
835
+ const leavingTransitionCover = createAnimation();
836
+ const leavingTransitionShadow = createAnimation();
837
+
838
+ leavingTransitionEffect
839
+ .addElement(leavingTransitionEffectEl)
840
+ .beforeStyles({ opacity: '1', display: 'block' })
841
+ .afterStyles({ opacity: '', display: '' });
842
+
843
+ leavingTransitionCover
844
+ .addElement(leavingTransitionCoverEl!) // REVIEW
845
+ .beforeClearStyles([OPACITY])
846
+ .fromTo(OPACITY, 0.1, 0);
847
+
848
+ leavingTransitionShadow
849
+ .addElement(leavingTransitionShadowEl!) // REVIEW
850
+ .beforeClearStyles([OPACITY])
851
+ .fromTo(OPACITY, 0.7, 0.03);
852
+
853
+ leavingTransitionEffect.addAnimation([leavingTransitionCover, leavingTransitionShadow]);
854
+ leavingContent.addAnimation([leavingTransitionEffect]);
855
+ }
856
+ }
857
+
858
+ leavingToolBarEls.forEach((leavingToolBarEl) => {
859
+ if (leavingToolBarEl.closest('ion-header')?.matches('.header-translucent:not(.ios26-disabled)')) {
860
+ return;
861
+ }
862
+ const leavingToolBar = createAnimation();
863
+ leavingToolBar.addElement(leavingToolBarEl);
864
+
865
+ const leavingTitle = createAnimation();
866
+ leavingTitle.addElement(leavingToolBarEl.querySelector('ion-title')!); // REVIEW
867
+
868
+ const leavingToolBarButtons = createAnimation();
869
+ const buttons = leavingToolBarEl.querySelectorAll('ion-buttons,[menuToggle]');
870
+
871
+ const parentHeader = leavingToolBarEl.closest('ion-header');
872
+ const inactiveHeader = parentHeader?.classList.contains('header-collapse-condense-inactive');
873
+
874
+ const buttonsToAnimate = Array.from(buttons).filter((button) => {
875
+ const isCollapseButton = button.classList.contains('buttons-collapse');
876
+ return (isCollapseButton && !inactiveHeader) || !isCollapseButton;
877
+ });
878
+
879
+ leavingToolBarButtons.addElement(buttonsToAnimate);
880
+
881
+ const leavingToolBarItems = createAnimation();
882
+ const leavingToolBarItemEls = leavingToolBarEl.querySelectorAll(':scope > *:not(ion-title):not(ion-buttons):not([menuToggle])');
883
+ if (leavingToolBarItemEls.length > 0) {
884
+ leavingToolBarItems.addElement(leavingToolBarItemEls);
885
+ }
886
+
887
+ const leavingToolBarBg = createAnimation();
888
+ leavingToolBarBg.addElement(shadow(leavingToolBarEl).querySelector('.toolbar-background')!); // REVIEW
889
+
890
+ const leavingBackButton = createAnimation();
891
+ const backButtonEl = leavingToolBarEl.querySelector('ion-back-button');
892
+ if (backButtonEl) {
893
+ leavingBackButton.addElement(backButtonEl);
894
+ }
895
+
896
+ leavingToolBar.addAnimation([leavingTitle, leavingToolBarButtons, leavingToolBarItems, leavingBackButton, leavingToolBarBg]);
897
+ rootAnimation.addAnimation(leavingToolBar);
898
+
899
+ // fade out leaving toolbar items
900
+ leavingBackButton.fromTo(OPACITY, 0.99, 0);
901
+
902
+ leavingToolBarButtons.fromTo(OPACITY, 0.99, 0);
903
+ leavingToolBarItems.fromTo(OPACITY, 0.99, 0);
904
+
905
+ if (backDirection) {
906
+ if (!inactiveHeader) {
907
+ // leaving toolbar, back direction
908
+ leavingTitle
909
+ .fromTo('transform', `translateX(${CENTER})`, isRTL ? 'translateX(-100%)' : 'translateX(100%)')
910
+ .fromTo(OPACITY, 0.99, 0);
911
+ }
912
+
913
+ leavingToolBarItems.fromTo('transform', `translateX(${CENTER})`, isRTL ? 'translateX(-100%)' : 'translateX(100%)');
914
+ leavingToolBarBg.beforeClearStyles([OPACITY, 'transform']);
915
+ // leaving toolbar, back direction, and there's no entering toolbar
916
+ // should just slide out, no fading out
917
+ const translucentHeader = parentHeader?.translucent;
918
+ if (!translucentHeader) {
919
+ leavingToolBarBg.fromTo(OPACITY, 'var(--opacity)', 0);
920
+ } else {
921
+ leavingToolBarBg.fromTo('transform', 'translateX(0px)', isRTL ? 'translateX(-100%)' : 'translateX(100%)');
922
+ }
923
+
924
+ if (backButtonEl) {
925
+ const leavingBackBtnText = createAnimation();
926
+ leavingBackBtnText
927
+ .addElement(shadow(backButtonEl).querySelector('.button-text')!) // REVIEW
928
+ .fromTo('transform', `translateX(${CENTER})`, `translateX(${(isRTL ? -124 : 124) + 'px'})`);
929
+ leavingToolBar.addAnimation(leavingBackBtnText);
930
+ }
931
+ } else {
932
+ // leaving toolbar, forward direction
933
+ if (!inactiveHeader) {
934
+ leavingTitle
935
+ .fromTo('transform', `translateX(${CENTER})`, `translateX(${OFF_LEFT})`)
936
+ .fromTo(OPACITY, 0.99, 0)
937
+ .afterClearStyles([TRANSFORM, OPACITY]);
938
+ }
939
+
940
+ leavingToolBarItems
941
+ .fromTo('transform', `translateX(${CENTER})`, `translateX(${OFF_LEFT})`)
942
+ .afterClearStyles([TRANSFORM, OPACITY]);
943
+
944
+ leavingBackButton.afterClearStyles([OPACITY]);
945
+ leavingTitle.afterClearStyles([OPACITY]);
946
+ leavingToolBarButtons.afterClearStyles([OPACITY]);
947
+ }
948
+ });
949
+ }
950
+
951
+ return rootAnimation;
952
+ } catch (err) {
953
+ throw err;
954
+ }
955
+ };
956
+
957
+ /**
958
+ * The scale of the back button during the animation
959
+ * is computed based on the scale of the large title
960
+ * and vice versa. However, we need to account for slight
961
+ * variations in the size of the large title due to
962
+ * padding and font weight. This value should be used to subtract
963
+ * a small amount from the large title height when computing scales
964
+ * to get more accurate scale results.
965
+ */
966
+ const LARGE_TITLE_SIZE_OFFSET = 10;