@rdlabo/ionic-theme-ios27 0.1.0-beta.pr154.shac3e35365120e → 0.1.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 (95) hide show
  1. package/README.md +3 -3
  2. package/dist/css/components/ion-action-sheet.css +1 -1
  3. package/dist/css/components/ion-alert.css +1 -1
  4. package/dist/css/components/ion-button.css +1 -1
  5. package/dist/css/components/ion-card.css +1 -1
  6. package/dist/css/components/ion-fab.css +1 -1
  7. package/dist/css/components/ion-list.css +1 -1
  8. package/dist/css/components/ion-menu.css +1 -1
  9. package/dist/css/components/ion-modal.css +1 -1
  10. package/dist/css/components/ion-popover.css +1 -1
  11. package/dist/css/components/ion-range.css +1 -1
  12. package/dist/css/components/ion-segment.css +1 -1
  13. package/dist/css/components/ion-tabs.css +1 -1
  14. package/dist/css/components/ion-toast.css +1 -1
  15. package/dist/css/components/ion-toolbar.css +1 -1
  16. package/dist/css/default-variables.css +1 -1
  17. package/dist/css/ionic-theme-ios27-dark-always.css +1 -1
  18. package/dist/css/ionic-theme-ios27-dark-class.css +1 -1
  19. package/dist/css/ionic-theme-ios27-dark-system.css +1 -1
  20. package/dist/css/ionic-theme-ios27.css +1 -1
  21. package/dist/css/md-ion-list-inset.css +1 -1
  22. package/dist/css/utils/dark/ion-list.css +1 -0
  23. package/dist/css/utils/group-heading.css +1 -0
  24. package/dist/native/components/searchable-tabs.d.ts.map +1 -1
  25. package/dist/native/components/searchable-tabs.js +9 -1
  26. package/dist/native/definitions.d.ts +4 -0
  27. package/dist/native/definitions.d.ts.map +1 -1
  28. package/dist/native/runtime.d.ts.map +1 -1
  29. package/dist/native/runtime.js +51 -27
  30. package/dist/native/shared/candidate.d.ts.map +1 -1
  31. package/dist/native/shared/candidate.js +17 -0
  32. package/dist/native/shared/crossfade.d.ts +8 -0
  33. package/dist/native/shared/crossfade.d.ts.map +1 -0
  34. package/dist/native/shared/crossfade.js +46 -0
  35. package/dist/native/shared/dom.d.ts.map +1 -1
  36. package/dist/native/shared/dom.js +2 -1
  37. package/dist/popover/animations/ios.enter.d.ts.map +1 -1
  38. package/dist/popover/animations/ios.enter.js +105 -9
  39. package/dist/popover/animations/ios.leave.d.ts.map +1 -1
  40. package/dist/popover/animations/ios.leave.js +15 -1
  41. package/dist/popover/callout-surface.d.ts +2 -0
  42. package/dist/popover/callout-surface.d.ts.map +1 -0
  43. package/dist/popover/callout-surface.js +44 -0
  44. package/dist/sheets-of-glass/index.js +2 -1
  45. package/dist/transition/ios.transition.d.ts.map +1 -1
  46. package/dist/transition/ios.transition.js +0 -223
  47. package/docs/experimental-animation.md +3 -3
  48. package/docs/features.md +7 -2
  49. package/docs/native-ui-shell.md +9 -5
  50. package/docs/special-markup.md +17 -0
  51. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellButton.swift +7 -2
  52. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellSearchController.swift +10 -0
  53. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellSegment.swift +47 -15
  54. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellTabBar.swift +42 -7
  55. package/ios/Sources/IonicNativeUIShellPlugin/IonicNativeUIShellPlugin.swift +13 -6
  56. package/ios/Sources/IonicNativeUIShellPlugin/Shared/ShellCrossfade.swift +35 -0
  57. package/ios/Sources/IonicNativeUIShellPlugin/Shared/ShellSnapshot.swift +6 -1
  58. package/ios/Tests/IonicNativeUIShellPluginTests/ShellSnapshotTests.swift +59 -0
  59. package/package.json +1 -1
  60. package/src/native/components/searchable-tabs.ts +12 -1
  61. package/src/native/definitions.ts +4 -0
  62. package/src/native/runtime.ts +54 -31
  63. package/src/native/shared/candidate.ts +19 -0
  64. package/src/native/shared/crossfade.ts +49 -0
  65. package/src/native/shared/dom.ts +4 -1
  66. package/src/popover/animations/ios.enter.ts +123 -10
  67. package/src/popover/animations/ios.leave.ts +15 -1
  68. package/src/popover/callout-surface.ts +54 -0
  69. package/src/sheets-of-glass/index.ts +2 -2
  70. package/src/styles/components/ion-action-sheet.scss +35 -17
  71. package/src/styles/components/ion-alert.scss +51 -31
  72. package/src/styles/components/ion-button.scss +4 -7
  73. package/src/styles/components/ion-card.scss +64 -3
  74. package/src/styles/components/ion-fab.scss +3 -5
  75. package/src/styles/components/ion-list.scss +14 -1
  76. package/src/styles/components/ion-menu.scss +19 -7
  77. package/src/styles/components/ion-modal.scss +63 -14
  78. package/src/styles/components/ion-popover.scss +52 -9
  79. package/src/styles/components/ion-range.scss +49 -50
  80. package/src/styles/components/ion-segment.scss +15 -16
  81. package/src/styles/components/ion-tabs.scss +73 -13
  82. package/src/styles/components/ion-toast.scss +16 -25
  83. package/src/styles/components/ion-toolbar.scss +17 -1
  84. package/src/styles/default-variables.scss +4 -0
  85. package/src/styles/utils/_glass.scss +96 -0
  86. package/src/styles/utils/api.scss +46 -4
  87. package/src/styles/utils/dark/ion-button.scss +13 -0
  88. package/src/styles/utils/dark/ion-fab.scss +9 -0
  89. package/src/styles/utils/dark/ion-list.scss +7 -0
  90. package/src/styles/utils/dark/ion-segment.scss +8 -3
  91. package/src/styles/utils/dark/ion-tabs.scss +20 -0
  92. package/src/styles/utils/group-heading.scss +5 -0
  93. package/src/styles/utils/structured-list.scss +68 -15
  94. package/src/styles/utils/theme-dark.scss +23 -0
  95. package/src/transition/ios.transition.ts +0 -487
@@ -6,8 +6,6 @@ import { connectNativeUIShellTransition } from '../native-integration';
6
6
 
7
7
  const DURATION = 540;
8
8
 
9
- // TODO(FW-2832): types
10
-
11
9
  const getClonedElement = <T extends HTMLIonBackButtonElement | HTMLIonTitleElement>(tagName: string) => {
12
10
  return document.querySelector<T>(`${tagName}.ion-cloned-element`);
13
11
  };
@@ -119,480 +117,6 @@ const animateFixedBackButton = (
119
117
  root.addAnimation(animation);
120
118
  };
121
119
 
122
- const getLargeTitle = (refEl: any) => {
123
- const tabs = refEl.tagName === 'ION-TABS' ? refEl : refEl.querySelector('ion-tabs');
124
- const query = 'ion-content ion-header:not(.header-collapse-condense-inactive) ion-title.title-large';
125
-
126
- if (tabs != null) {
127
- const activeTab = tabs.querySelector('ion-tab:not(.tab-hidden), .ion-page:not(.ion-page-hidden)');
128
- return activeTab != null ? activeTab.querySelector(query) : null;
129
- }
130
-
131
- return refEl.querySelector(query);
132
- };
133
-
134
- const getBackButton = (refEl: any, backDirection: boolean) => {
135
- const tabs = refEl.tagName === 'ION-TABS' ? refEl : refEl.querySelector('ion-tabs');
136
- let buttonsList = [];
137
-
138
- if (tabs != null) {
139
- const activeTab = tabs.querySelector('ion-tab:not(.tab-hidden), .ion-page:not(.ion-page-hidden)');
140
- if (activeTab != null) {
141
- buttonsList = activeTab.querySelectorAll('ion-buttons');
142
- }
143
- } else {
144
- buttonsList = refEl.querySelectorAll('ion-buttons');
145
- }
146
-
147
- for (const buttons of buttonsList) {
148
- const parentHeader = buttons.closest('ion-header');
149
- const activeHeader = parentHeader && !parentHeader.classList.contains('header-collapse-condense-inactive');
150
- const backButton = buttons.querySelector('ion-back-button');
151
- const buttonsCollapse = buttons.classList.contains('buttons-collapse');
152
- const startSlot = buttons.slot === 'start' || buttons.slot === '';
153
-
154
- if (backButton !== null && startSlot && ((buttonsCollapse && activeHeader && backDirection) || !buttonsCollapse)) {
155
- return backButton;
156
- }
157
- }
158
-
159
- return null;
160
- };
161
-
162
- const createLargeTitleTransition = (
163
- rootAnimation: Animation,
164
- rtl: boolean,
165
- backDirection: boolean,
166
- enteringEl: HTMLElement,
167
- leavingEl: HTMLElement | undefined,
168
- ) => {
169
- const enteringBackButton = getBackButton(enteringEl, backDirection);
170
- const leavingLargeTitle = getLargeTitle(leavingEl);
171
-
172
- const enteringLargeTitle = getLargeTitle(enteringEl);
173
- const leavingBackButton = getBackButton(leavingEl, backDirection);
174
-
175
- const shouldAnimationForward = enteringBackButton !== null && leavingLargeTitle !== null && !backDirection;
176
- const shouldAnimationBackward = enteringLargeTitle !== null && leavingBackButton !== null && backDirection;
177
-
178
- if (shouldAnimationForward) {
179
- const leavingLargeTitleBox = leavingLargeTitle.getBoundingClientRect();
180
- const enteringBackButtonBox = enteringBackButton.getBoundingClientRect();
181
-
182
- const enteringBackButtonTextEl = shadow(enteringBackButton).querySelector('.button-text');
183
-
184
- // Text element not rendered if developers pass text="" to the back button
185
- const enteringBackButtonTextBox = enteringBackButtonTextEl?.getBoundingClientRect();
186
-
187
- const leavingLargeTitleTextEl = shadow(leavingLargeTitle).querySelector('.toolbar-title')!;
188
- const leavingLargeTitleTextBox = leavingLargeTitleTextEl.getBoundingClientRect();
189
-
190
- animateLargeTitle(
191
- rootAnimation,
192
- rtl,
193
- backDirection,
194
- leavingLargeTitle,
195
- leavingLargeTitleBox,
196
- leavingLargeTitleTextBox,
197
- enteringBackButtonBox,
198
- enteringBackButtonTextEl,
199
- enteringBackButtonTextBox,
200
- );
201
- // animateBackButton(
202
- // rootAnimation,
203
- // rtl,
204
- // backDirection,
205
- // enteringBackButton,
206
- // enteringBackButtonBox,
207
- // enteringBackButtonTextEl,
208
- // enteringBackButtonTextBox,
209
- // leavingLargeTitle,
210
- // leavingLargeTitleTextBox,
211
- // );
212
- } else if (shouldAnimationBackward) {
213
- const enteringLargeTitleBox = enteringLargeTitle.getBoundingClientRect();
214
- const leavingBackButtonBox = leavingBackButton.getBoundingClientRect();
215
-
216
- const leavingBackButtonTextEl = shadow(leavingBackButton).querySelector('.button-text');
217
-
218
- // Text element not rendered if developers pass text="" to the back button
219
- const leavingBackButtonTextBox = leavingBackButtonTextEl?.getBoundingClientRect();
220
-
221
- const enteringLargeTitleTextEl = shadow(enteringLargeTitle).querySelector('.toolbar-title')!;
222
- const enteringLargeTitleTextBox = enteringLargeTitleTextEl.getBoundingClientRect();
223
-
224
- animateLargeTitle(
225
- rootAnimation,
226
- rtl,
227
- backDirection,
228
- enteringLargeTitle,
229
- enteringLargeTitleBox,
230
- enteringLargeTitleTextBox,
231
- leavingBackButtonBox,
232
- leavingBackButtonTextEl,
233
- leavingBackButtonTextBox,
234
- );
235
- // animateBackButton(
236
- // rootAnimation,
237
- // rtl,
238
- // backDirection,
239
- // leavingBackButton,
240
- // leavingBackButtonBox,
241
- // leavingBackButtonTextEl,
242
- // leavingBackButtonTextBox,
243
- // enteringLargeTitle,
244
- // enteringLargeTitleTextBox,
245
- // );
246
- }
247
-
248
- return {
249
- forward: shouldAnimationForward,
250
- backward: shouldAnimationBackward,
251
- };
252
- };
253
-
254
- const animateBackButton = (
255
- rootAnimation: Animation,
256
- rtl: boolean,
257
- backDirection: boolean,
258
- backButtonEl: HTMLIonBackButtonElement,
259
- backButtonBox: DOMRect,
260
- backButtonTextEl: HTMLElement | null,
261
- backButtonTextBox: DOMRect | undefined,
262
- largeTitleEl: HTMLIonTitleElement,
263
- largeTitleTextBox: DOMRect,
264
- ) => {
265
- const BACK_BUTTON_START_OFFSET = rtl ? `calc(100% - ${backButtonBox.right + 4}px)` : `${backButtonBox.left - 4}px`;
266
-
267
- const TEXT_ORIGIN_X = rtl ? 'right' : 'left';
268
- const ICON_ORIGIN_X = rtl ? 'left' : 'right';
269
-
270
- const CONTAINER_ORIGIN_X = rtl ? 'right' : 'left';
271
- let WIDTH_SCALE = 1;
272
- let HEIGHT_SCALE = 1;
273
-
274
- let TEXT_START_SCALE = `scale(${HEIGHT_SCALE})`;
275
- const TEXT_END_SCALE = 'scale(1)';
276
-
277
- if (backButtonTextEl && backButtonTextBox) {
278
- /**
279
- * When the title and back button texts match then they should overlap during the
280
- * page transition. If the texts do not match up then the back button text scale
281
- * adjusts to not perfectly match the large title text otherwise the proportions
282
- * will be incorrect. When the texts match we scale both the width and height to
283
- * account for font weight differences between the title and back button.
284
- */
285
- const doTitleAndButtonTextsMatch = backButtonTextEl.textContent?.trim() === largeTitleEl.textContent?.trim();
286
- WIDTH_SCALE = largeTitleTextBox.width / backButtonTextBox.width;
287
- /**
288
- * Subtract an offset to account for slight sizing/padding differences between the
289
- * title and the back button.
290
- */
291
- HEIGHT_SCALE = (largeTitleTextBox.height - LARGE_TITLE_SIZE_OFFSET) / backButtonTextBox.height;
292
-
293
- /**
294
- * Even though we set TEXT_START_SCALE to HEIGHT_SCALE above, we potentially need
295
- * to re-compute this here since the HEIGHT_SCALE may have changed.
296
- */
297
- TEXT_START_SCALE = doTitleAndButtonTextsMatch ? `scale(${WIDTH_SCALE}, ${HEIGHT_SCALE})` : `scale(${HEIGHT_SCALE})`;
298
- }
299
-
300
- const backButtonIconEl = shadow(backButtonEl).querySelector('ion-icon')!;
301
- const backButtonIconBox = backButtonIconEl.getBoundingClientRect();
302
-
303
- /**
304
- * We need to offset the container by the icon dimensions
305
- * so that the back button text aligns with the large title
306
- * text. Otherwise, the back button icon will align with the
307
- * large title text but the back button text will not.
308
- */
309
- const CONTAINER_START_TRANSLATE_X = rtl
310
- ? `${backButtonIconBox.width / 2 - (backButtonIconBox.right - backButtonBox.right)}px`
311
- : `${backButtonBox.left - backButtonIconBox.width / 2}px`;
312
- const CONTAINER_END_TRANSLATE_X = rtl ? `-${window.innerWidth - backButtonBox.right}px` : `${backButtonBox.left}px`;
313
-
314
- /**
315
- * Back button container should be
316
- * aligned to the top of the title container
317
- * so the texts overlap as the back button
318
- * text begins to fade in.
319
- */
320
- const CONTAINER_START_TRANSLATE_Y = `${largeTitleTextBox.top}px`;
321
-
322
- /**
323
- * The cloned back button should align exactly with the
324
- * real back button on the entering page otherwise there will
325
- * be a layout shift.
326
- */
327
- const CONTAINER_END_TRANSLATE_Y = `${backButtonBox.top}px`;
328
-
329
- /**
330
- * In the forward direction, the cloned back button
331
- * container should translate from over the large title
332
- * to over the back button. In the backward direction,
333
- * it should translate from over the back button to over
334
- * the large title.
335
- */
336
- const FORWARD_CONTAINER_KEYFRAMES = [
337
- { offset: 0, transform: `translate3d(${CONTAINER_START_TRANSLATE_X}, ${CONTAINER_START_TRANSLATE_Y}, 0)` },
338
- { offset: 1, transform: `translate3d(${CONTAINER_END_TRANSLATE_X}, ${CONTAINER_END_TRANSLATE_Y}, 0)` },
339
- ];
340
- const BACKWARD_CONTAINER_KEYFRAMES = [
341
- { offset: 0, transform: `translate3d(${CONTAINER_END_TRANSLATE_X}, ${CONTAINER_END_TRANSLATE_Y}, 0)` },
342
- { offset: 1, transform: `translate3d(${CONTAINER_START_TRANSLATE_X}, ${CONTAINER_START_TRANSLATE_Y}, 0)` },
343
- ];
344
- const CONTAINER_KEYFRAMES = backDirection ? BACKWARD_CONTAINER_KEYFRAMES : FORWARD_CONTAINER_KEYFRAMES;
345
-
346
- /**
347
- * In the forward direction, the text in the cloned back button
348
- * should start to be (roughly) the size of the large title
349
- * and then scale down to be the size of the actual back button.
350
- * The text should also translate, but that translate is handled
351
- * by the container keyframes.
352
- */
353
- const FORWARD_TEXT_KEYFRAMES = [
354
- { offset: 0, opacity: 0, transform: TEXT_START_SCALE },
355
- { offset: 1, opacity: 1, transform: TEXT_END_SCALE },
356
- ];
357
- const BACKWARD_TEXT_KEYFRAMES = [
358
- { offset: 0, opacity: 1, transform: TEXT_END_SCALE },
359
- { offset: 1, opacity: 0, transform: TEXT_START_SCALE },
360
- ];
361
- const TEXT_KEYFRAMES = backDirection ? BACKWARD_TEXT_KEYFRAMES : FORWARD_TEXT_KEYFRAMES;
362
-
363
- /**
364
- * The icon should scale in/out in the second
365
- * half of the animation. The icon should also
366
- * translate, but that translate is handled by the
367
- * container keyframes.
368
- */
369
- const FORWARD_ICON_KEYFRAMES = [
370
- { offset: 0, opacity: 0, transform: 'scale(0.6)' },
371
- { offset: 0.6, opacity: 0, transform: 'scale(0.6)' },
372
- { offset: 1, opacity: 1, transform: 'scale(1)' },
373
- ];
374
- const BACKWARD_ICON_KEYFRAMES = [
375
- { offset: 0, opacity: 1, transform: 'scale(1)' },
376
- { offset: 0.2, opacity: 0, transform: 'scale(0.6)' },
377
- { offset: 1, opacity: 0, transform: 'scale(0.6)' },
378
- ];
379
- const ICON_KEYFRAMES = backDirection ? BACKWARD_ICON_KEYFRAMES : FORWARD_ICON_KEYFRAMES;
380
-
381
- const enteringBackButtonTextAnimation = createAnimation();
382
- const enteringBackButtonIconAnimation = createAnimation();
383
- const enteringBackButtonAnimation = createAnimation();
384
-
385
- const clonedBackButtonEl = getClonedElement<HTMLIonBackButtonElement>('ion-back-button')!;
386
-
387
- const clonedBackButtonTextEl = shadow(clonedBackButtonEl).querySelector('.button-text')!;
388
- const clonedBackButtonIconEl = shadow(clonedBackButtonEl).querySelector('ion-icon')!;
389
-
390
- clonedBackButtonEl.text = backButtonEl.text;
391
- clonedBackButtonEl.mode = backButtonEl.mode;
392
- clonedBackButtonEl.icon = backButtonEl.icon;
393
- clonedBackButtonEl.color = backButtonEl.color;
394
- clonedBackButtonEl.disabled = backButtonEl.disabled;
395
-
396
- clonedBackButtonEl.style.setProperty('display', 'block');
397
- clonedBackButtonEl.style.setProperty('position', 'fixed');
398
-
399
- enteringBackButtonIconAnimation.addElement(clonedBackButtonIconEl);
400
- enteringBackButtonTextAnimation.addElement(clonedBackButtonTextEl);
401
- enteringBackButtonAnimation.addElement(clonedBackButtonEl);
402
-
403
- enteringBackButtonAnimation
404
- .beforeStyles({
405
- position: 'absolute',
406
- top: '0px',
407
- [CONTAINER_ORIGIN_X]: '0px',
408
- })
409
- /**
410
- * The write hooks must be set on this animation as it is guaranteed to run. Other
411
- * animations such as the back button text animation will not run if the back button
412
- * has no visible text.
413
- */
414
- .beforeAddWrite(() => {
415
- backButtonEl.style.setProperty('display', 'none');
416
- clonedBackButtonEl.style.setProperty(TEXT_ORIGIN_X, BACK_BUTTON_START_OFFSET);
417
- })
418
- .afterAddWrite(() => {
419
- backButtonEl.style.setProperty('display', '');
420
- clonedBackButtonEl.style.setProperty('display', 'none');
421
- clonedBackButtonEl.style.removeProperty(TEXT_ORIGIN_X);
422
- })
423
- .keyframes(CONTAINER_KEYFRAMES);
424
-
425
- enteringBackButtonTextAnimation
426
- .beforeStyles({
427
- 'transform-origin': `${TEXT_ORIGIN_X} top`,
428
- })
429
- .keyframes(TEXT_KEYFRAMES);
430
-
431
- enteringBackButtonIconAnimation
432
- .beforeStyles({
433
- 'transform-origin': `${ICON_ORIGIN_X} center`,
434
- })
435
- .keyframes(ICON_KEYFRAMES);
436
-
437
- rootAnimation.addAnimation([enteringBackButtonTextAnimation, enteringBackButtonIconAnimation, enteringBackButtonAnimation]);
438
- };
439
-
440
- const animateLargeTitle = (
441
- rootAnimation: Animation,
442
- rtl: boolean,
443
- backDirection: boolean,
444
- largeTitleEl: HTMLIonTitleElement,
445
- largeTitleBox: DOMRect,
446
- largeTitleTextBox: DOMRect,
447
- backButtonBox: DOMRect,
448
- backButtonTextEl: HTMLElement | null,
449
- backButtonTextBox: DOMRect | undefined,
450
- ) => {
451
- /**
452
- * The horizontal transform origin for the large title
453
- */
454
- const ORIGIN_X = rtl ? 'right' : 'left';
455
-
456
- const TITLE_START_OFFSET = rtl ? `calc(100% - ${largeTitleBox.right}px)` : `${largeTitleBox.left}px`;
457
-
458
- /**
459
- * The cloned large should align exactly with the
460
- * real large title on the leaving page otherwise there will
461
- * be a layout shift.
462
- */
463
- const START_TRANSLATE_X = '0px';
464
- const START_TRANSLATE_Y = `${largeTitleBox.top}px`;
465
-
466
- /**
467
- * How much to offset the large title translation by.
468
- * This accounts for differences in sizing between the large
469
- * title and the back button due to padding and font weight.
470
- */
471
- const LARGE_TITLE_TRANSLATION_OFFSET = 8;
472
- let END_TRANSLATE_X = rtl
473
- ? `-${window.innerWidth - backButtonBox.right - LARGE_TITLE_TRANSLATION_OFFSET}px`
474
- : `${backButtonBox.x + LARGE_TITLE_TRANSLATION_OFFSET}px`;
475
-
476
- /**
477
- * How much to scale the large title up/down by.
478
- */
479
- let HEIGHT_SCALE = 0.5;
480
-
481
- /**
482
- * The large title always starts full size.
483
- */
484
- const START_SCALE = 'scale(1)';
485
-
486
- /**
487
- * By default, we don't worry about having the large title scaled to perfectly
488
- * match the back button because we don't know if the back button's text matches
489
- * the large title's text.
490
- */
491
- let END_SCALE = `scale(${HEIGHT_SCALE})`;
492
-
493
- // Text element not rendered if developers pass text="" to the back button
494
- if (backButtonTextEl && backButtonTextBox) {
495
- /**
496
- * The scaled title should (roughly) overlap the back button. This ensures that
497
- * the back button and title overlap during the animation. Note that since both
498
- * elements either fade in or fade out over the course of the animation, neither
499
- * element will be fully visible on top of the other. As a result, the overlap
500
- * does not need to be perfect, so approximate values are acceptable here.
501
- */
502
- END_TRANSLATE_X = rtl
503
- ? `-${window.innerWidth - backButtonTextBox.right - LARGE_TITLE_TRANSLATION_OFFSET}px`
504
- : `${backButtonTextBox.x - LARGE_TITLE_TRANSLATION_OFFSET}px`;
505
-
506
- /**
507
- * In the forward direction, the large title should start at its normal size and
508
- * then scale down to be (roughly) the size of the back button on the other view.
509
- * In the backward direction, the large title should start at (roughly) the size
510
- * of the back button and then scale up to its original size.
511
- * Note that since both elements either fade in or fade out over the course of the
512
- * animation, neither element will be fully visible on top of the other. As a result,
513
- * the overlap does not need to be perfect, so approximate values are acceptable here.
514
- */
515
-
516
- /**
517
- * When the title and back button texts match then they should overlap during the
518
- * page transition. If the texts do not match up then the large title text scale
519
- * adjusts to not perfectly match the back button text otherwise the proportions
520
- * will be incorrect. When the texts match we scale both the width and height to
521
- * account for font weight differences between the title and back button.
522
- */
523
- const doTitleAndButtonTextsMatch = backButtonTextEl.textContent?.trim() === largeTitleEl.textContent?.trim();
524
-
525
- const WIDTH_SCALE = backButtonTextBox.width / largeTitleTextBox.width;
526
- HEIGHT_SCALE = backButtonTextBox.height / (largeTitleTextBox.height - LARGE_TITLE_SIZE_OFFSET);
527
-
528
- /**
529
- * Even though we set TEXT_START_SCALE to HEIGHT_SCALE above, we potentially need
530
- * to re-compute this here since the HEIGHT_SCALE may have changed.
531
- */
532
- END_SCALE = doTitleAndButtonTextsMatch ? `scale(${WIDTH_SCALE}, ${HEIGHT_SCALE})` : `scale(${HEIGHT_SCALE})`;
533
- }
534
-
535
- /**
536
- * The midpoints of the back button and the title should align such that the back
537
- * button and title appear to be centered with each other.
538
- */
539
- const backButtonMidPoint = backButtonBox.top + backButtonBox.height / 2;
540
- const titleMidPoint = (largeTitleBox.height * HEIGHT_SCALE) / 2;
541
- const END_TRANSLATE_Y = `${backButtonMidPoint - titleMidPoint}px`;
542
-
543
- const BACKWARDS_KEYFRAMES = [
544
- { offset: 0, opacity: 0, transform: `translate3d(${END_TRANSLATE_X}, ${END_TRANSLATE_Y}, 0) ${END_SCALE}` },
545
- { offset: 0.1, opacity: 0 },
546
- { offset: 1, opacity: 1, transform: `translate3d(${START_TRANSLATE_X}, ${START_TRANSLATE_Y}, 0) ${START_SCALE}` },
547
- ];
548
- const FORWARDS_KEYFRAMES = [
549
- {
550
- offset: 0,
551
- opacity: 0.99,
552
- transform: `translate3d(${START_TRANSLATE_X}, ${START_TRANSLATE_Y}, 0) ${START_SCALE}`,
553
- },
554
- { offset: 0.6, opacity: 0 },
555
- { offset: 1, opacity: 0, transform: `translate3d(${END_TRANSLATE_X}, ${END_TRANSLATE_Y}, 0) ${END_SCALE}` },
556
- ];
557
-
558
- const KEYFRAMES = backDirection ? BACKWARDS_KEYFRAMES : FORWARDS_KEYFRAMES;
559
-
560
- const clonedTitleEl = getClonedElement<HTMLIonTitleElement>('ion-title')!;
561
- const clonedLargeTitleAnimation = createAnimation();
562
-
563
- clonedTitleEl.innerText = largeTitleEl.innerText;
564
- clonedTitleEl.size = largeTitleEl.size;
565
- clonedTitleEl.color = largeTitleEl.color;
566
-
567
- clonedLargeTitleAnimation.addElement(clonedTitleEl);
568
-
569
- clonedLargeTitleAnimation
570
- .beforeStyles({
571
- 'transform-origin': `${ORIGIN_X} top`,
572
-
573
- /**
574
- * Since font size changes will cause
575
- * the dimension of the large title to change
576
- * we need to set the cloned title height
577
- * equal to that of the original large title height.
578
- */
579
- height: `${largeTitleBox.height}px`,
580
- display: '',
581
- position: 'relative',
582
- [ORIGIN_X]: TITLE_START_OFFSET,
583
- })
584
- .beforeAddWrite(() => {
585
- largeTitleEl.style.setProperty('opacity', '0');
586
- })
587
- .afterAddWrite(() => {
588
- largeTitleEl.style.setProperty('opacity', '');
589
- clonedTitleEl.style.setProperty('display', 'none');
590
- })
591
- .keyframes(KEYFRAMES);
592
-
593
- rootAnimation.addAnimation(clonedLargeTitleAnimation);
594
- };
595
-
596
120
  export const iosTransitionAnimation = (navEl: HTMLElement, opts: TransitionOptions): Animation => {
597
121
  try {
598
122
  const EASING = 'cubic-bezier(0.32,0.72,0,1)';
@@ -958,14 +482,3 @@ export const iosTransitionAnimation = (navEl: HTMLElement, opts: TransitionOptio
958
482
  throw err;
959
483
  }
960
484
  };
961
-
962
- /**
963
- * The scale of the back button during the animation
964
- * is computed based on the scale of the large title
965
- * and vice versa. However, we need to account for slight
966
- * variations in the size of the large title due to
967
- * padding and font weight. This value should be used to subtract
968
- * a small amount from the large title height when computing scales
969
- * to get more accurate scale results.
970
- */
971
- const LARGE_TITLE_SIZE_OFFSET = 10;