@ionic/core 8.0.2-nightly.20240430 → 8.0.2

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 (52) hide show
  1. package/components/ios.transition.js +94 -67
  2. package/dist/cjs/{index-1a575e52.js → index-6047957b.js} +2 -2
  3. package/dist/cjs/index.cjs.js +3 -3
  4. package/dist/cjs/ion-app_8.cjs.entry.js +1 -1
  5. package/dist/cjs/ion-modal.cjs.entry.js +1 -1
  6. package/dist/cjs/ion-nav_2.cjs.entry.js +1 -1
  7. package/dist/cjs/ion-popover.cjs.entry.js +1 -1
  8. package/dist/cjs/{ios.transition-2b4db49c.js → ios.transition-59b0e1d9.js} +95 -68
  9. package/dist/cjs/{md.transition-8f3e1081.js → md.transition-0cc7c831.js} +1 -1
  10. package/dist/collection/utils/transition/ios.transition.js +94 -67
  11. package/dist/docs.json +1 -1
  12. package/dist/esm/{index-4db06e9f.js → index-f4460246.js} +2 -2
  13. package/dist/esm/index.js +3 -3
  14. package/dist/esm/ion-app_8.entry.js +1 -1
  15. package/dist/esm/ion-modal.entry.js +1 -1
  16. package/dist/esm/ion-nav_2.entry.js +1 -1
  17. package/dist/esm/ion-popover.entry.js +1 -1
  18. package/dist/esm/{ios.transition-f4d34857.js → ios.transition-72f59adb.js} +95 -68
  19. package/dist/esm/{md.transition-995aadd3.js → md.transition-ef0437fe.js} +1 -1
  20. package/dist/esm-es5/{index-4db06e9f.js → index-f4460246.js} +1 -1
  21. package/dist/esm-es5/index.js +1 -1
  22. package/dist/esm-es5/ion-app_8.entry.js +1 -1
  23. package/dist/esm-es5/ion-modal.entry.js +1 -1
  24. package/dist/esm-es5/ion-nav_2.entry.js +1 -1
  25. package/dist/esm-es5/ion-popover.entry.js +1 -1
  26. package/dist/esm-es5/ios.transition-72f59adb.js +4 -0
  27. package/dist/esm-es5/{md.transition-995aadd3.js → md.transition-ef0437fe.js} +1 -1
  28. package/dist/ionic/index.esm.js +1 -1
  29. package/dist/ionic/ionic.esm.js +1 -1
  30. package/dist/ionic/{p-c4c33a40.system.entry.js → p-16b35bc9.system.entry.js} +1 -1
  31. package/dist/ionic/{p-112831e6.system.entry.js → p-19d50867.system.entry.js} +1 -1
  32. package/dist/ionic/p-30baae57.system.js +1 -1
  33. package/dist/ionic/{p-f59976c0.entry.js → p-3bece4aa.entry.js} +1 -1
  34. package/dist/ionic/{p-7b6b80ac.system.entry.js → p-439b8b3c.system.entry.js} +1 -1
  35. package/dist/ionic/{p-4a01da1d.entry.js → p-657157d7.entry.js} +1 -1
  36. package/dist/ionic/p-6636ef29.js +4 -0
  37. package/dist/ionic/p-6a5fe8b0.js +4 -0
  38. package/dist/ionic/{p-aec59006.entry.js → p-99c42ae3.entry.js} +1 -1
  39. package/dist/ionic/p-aa71aee7.js +4 -0
  40. package/dist/ionic/p-b4a034c8.system.js +4 -0
  41. package/dist/ionic/{p-adb59652.system.entry.js → p-b6d4e78d.system.entry.js} +1 -1
  42. package/dist/ionic/{p-505b2f62.system.js → p-cab332d1.system.js} +1 -1
  43. package/dist/ionic/{p-c1842a35.entry.js → p-e95ac94c.entry.js} +1 -1
  44. package/dist/ionic/{p-8cfb179c.system.js → p-f14daa66.system.js} +1 -1
  45. package/dist/ionic/{p-e0b881ae.system.js → p-f2026596.system.js} +1 -1
  46. package/hydrate/index.js +100 -73
  47. package/package.json +1 -1
  48. package/dist/esm-es5/ios.transition-f4d34857.js +0 -4
  49. package/dist/ionic/p-1dc1efbd.system.js +0 -4
  50. package/dist/ionic/p-82a0493a.js +0 -4
  51. package/dist/ionic/p-ad445168.js +0 -4
  52. package/dist/ionic/p-b73d33a9.js +0 -4
@@ -56,20 +56,22 @@ const createLargeTitleTransition = (rootAnimation, rtl, backDirection, enteringE
56
56
  const leavingLargeTitleBox = leavingLargeTitle.getBoundingClientRect();
57
57
  const enteringBackButtonBox = enteringBackButton.getBoundingClientRect();
58
58
  const enteringBackButtonTextEl = shadow(enteringBackButton).querySelector('.button-text');
59
- const enteringBackButtonTextBox = enteringBackButtonTextEl.getBoundingClientRect();
59
+ // Text element not rendered if developers pass text="" to the back button
60
+ const enteringBackButtonTextBox = enteringBackButtonTextEl === null || enteringBackButtonTextEl === void 0 ? void 0 : enteringBackButtonTextEl.getBoundingClientRect();
60
61
  const leavingLargeTitleTextEl = shadow(leavingLargeTitle).querySelector('.toolbar-title');
61
62
  const leavingLargeTitleTextBox = leavingLargeTitleTextEl.getBoundingClientRect();
62
- animateLargeTitle(rootAnimation, rtl, backDirection, leavingLargeTitle, leavingLargeTitleBox, leavingLargeTitleTextBox, enteringBackButtonTextEl, enteringBackButtonTextBox);
63
+ animateLargeTitle(rootAnimation, rtl, backDirection, leavingLargeTitle, leavingLargeTitleBox, leavingLargeTitleTextBox, enteringBackButtonBox, enteringBackButtonTextEl, enteringBackButtonTextBox);
63
64
  animateBackButton(rootAnimation, rtl, backDirection, enteringBackButton, enteringBackButtonBox, enteringBackButtonTextEl, enteringBackButtonTextBox, leavingLargeTitle, leavingLargeTitleTextBox);
64
65
  }
65
66
  else if (shouldAnimationBackward) {
66
67
  const enteringLargeTitleBox = enteringLargeTitle.getBoundingClientRect();
67
68
  const leavingBackButtonBox = leavingBackButton.getBoundingClientRect();
68
69
  const leavingBackButtonTextEl = shadow(leavingBackButton).querySelector('.button-text');
69
- const leavingBackButtonTextBox = leavingBackButtonTextEl.getBoundingClientRect();
70
+ // Text element not rendered if developers pass text="" to the back button
71
+ const leavingBackButtonTextBox = leavingBackButtonTextEl === null || leavingBackButtonTextEl === void 0 ? void 0 : leavingBackButtonTextEl.getBoundingClientRect();
70
72
  const enteringLargeTitleTextEl = shadow(enteringLargeTitle).querySelector('.toolbar-title');
71
73
  const enteringLargeTitleTextBox = enteringLargeTitleTextEl.getBoundingClientRect();
72
- animateLargeTitle(rootAnimation, rtl, backDirection, enteringLargeTitle, enteringLargeTitleBox, enteringLargeTitleTextBox, leavingBackButtonTextEl, leavingBackButtonTextBox);
74
+ animateLargeTitle(rootAnimation, rtl, backDirection, enteringLargeTitle, enteringLargeTitleBox, enteringLargeTitleTextBox, leavingBackButtonBox, leavingBackButtonTextEl, leavingBackButtonTextBox);
73
75
  animateBackButton(rootAnimation, rtl, backDirection, leavingBackButton, leavingBackButtonBox, leavingBackButtonTextEl, leavingBackButtonTextBox, enteringLargeTitle, enteringLargeTitleTextBox);
74
76
  }
75
77
  return {
@@ -83,26 +85,31 @@ const animateBackButton = (rootAnimation, rtl, backDirection, backButtonEl, back
83
85
  const TEXT_ORIGIN_X = rtl ? 'right' : 'left';
84
86
  const ICON_ORIGIN_X = rtl ? 'left' : 'right';
85
87
  const CONTAINER_ORIGIN_X = rtl ? 'right' : 'left';
86
- /**
87
- * When the title and back button texts match
88
- * then they should overlap during the page transition.
89
- * If the texts do not match up then the back button text scale adjusts
90
- * to not perfectly match the large title text otherwise the
91
- * proportions will be incorrect.
92
- * When the texts match we scale both the width and height to account for
93
- * font weight differences between the title and back button.
94
- */
95
- const doTitleAndButtonTextsMatch = ((_a = backButtonTextEl.textContent) === null || _a === void 0 ? void 0 : _a.trim()) === ((_b = largeTitleEl.textContent) === null || _b === void 0 ? void 0 : _b.trim());
96
- const WIDTH_SCALE = largeTitleTextBox.width / backButtonTextBox.width;
97
- /**
98
- * We subtract an offset to account for slight sizing/padding
99
- * differences between the title and the back button.
100
- */
101
- const HEIGHT_SCALE = (largeTitleTextBox.height - LARGE_TITLE_SIZE_OFFSET) / backButtonTextBox.height;
102
- const TEXT_START_SCALE = doTitleAndButtonTextsMatch
103
- ? `scale(${WIDTH_SCALE}, ${HEIGHT_SCALE})`
104
- : `scale(${HEIGHT_SCALE})`;
88
+ let WIDTH_SCALE = 1;
89
+ let HEIGHT_SCALE = 1;
90
+ let TEXT_START_SCALE = `scale(${HEIGHT_SCALE})`;
105
91
  const TEXT_END_SCALE = 'scale(1)';
92
+ if (backButtonTextEl && backButtonTextBox) {
93
+ /**
94
+ * When the title and back button texts match then they should overlap during the
95
+ * page transition. If the texts do not match up then the back button text scale
96
+ * adjusts to not perfectly match the large title text otherwise the proportions
97
+ * will be incorrect. When the texts match we scale both the width and height to
98
+ * account for font weight differences between the title and back button.
99
+ */
100
+ const doTitleAndButtonTextsMatch = ((_a = backButtonTextEl.textContent) === null || _a === void 0 ? void 0 : _a.trim()) === ((_b = largeTitleEl.textContent) === null || _b === void 0 ? void 0 : _b.trim());
101
+ WIDTH_SCALE = largeTitleTextBox.width / backButtonTextBox.width;
102
+ /**
103
+ * Subtract an offset to account for slight sizing/padding differences between the
104
+ * title and the back button.
105
+ */
106
+ HEIGHT_SCALE = (largeTitleTextBox.height - LARGE_TITLE_SIZE_OFFSET) / backButtonTextBox.height;
107
+ /**
108
+ * Even though we set TEXT_START_SCALE to HEIGHT_SCALE above, we potentially need
109
+ * to re-compute this here since the HEIGHT_SCALE may have changed.
110
+ */
111
+ TEXT_START_SCALE = doTitleAndButtonTextsMatch ? `scale(${WIDTH_SCALE}, ${HEIGHT_SCALE})` : `scale(${HEIGHT_SCALE})`;
112
+ }
106
113
  const backButtonIconEl = shadow(backButtonEl).querySelector('ion-icon');
107
114
  const backButtonIconBox = backButtonIconEl.getBoundingClientRect();
108
115
  /**
@@ -199,11 +206,11 @@ const animateBackButton = (rootAnimation, rtl, backDirection, backButtonEl, back
199
206
  top: '0px',
200
207
  [CONTAINER_ORIGIN_X]: '0px',
201
208
  })
202
- .keyframes(CONTAINER_KEYFRAMES);
203
- enteringBackButtonTextAnimation
204
- .beforeStyles({
205
- 'transform-origin': `${TEXT_ORIGIN_X} top`,
206
- })
209
+ /**
210
+ * The write hooks must be set on this animation as it is guaranteed to run. Other
211
+ * animations such as the back button text animation will not run if the back button
212
+ * has no visible text.
213
+ */
207
214
  .beforeAddWrite(() => {
208
215
  backButtonEl.style.setProperty('display', 'none');
209
216
  clonedBackButtonEl.style.setProperty(TEXT_ORIGIN_X, BACK_BUTTON_START_OFFSET);
@@ -212,6 +219,11 @@ const animateBackButton = (rootAnimation, rtl, backDirection, backButtonEl, back
212
219
  backButtonEl.style.setProperty('display', '');
213
220
  clonedBackButtonEl.style.setProperty('display', 'none');
214
221
  clonedBackButtonEl.style.removeProperty(TEXT_ORIGIN_X);
222
+ })
223
+ .keyframes(CONTAINER_KEYFRAMES);
224
+ enteringBackButtonTextAnimation
225
+ .beforeStyles({
226
+ 'transform-origin': `${TEXT_ORIGIN_X} top`,
215
227
  })
216
228
  .keyframes(TEXT_KEYFRAMES);
217
229
  enteringBackButtonIconAnimation
@@ -225,7 +237,7 @@ const animateBackButton = (rootAnimation, rtl, backDirection, backButtonEl, back
225
237
  enteringBackButtonAnimation,
226
238
  ]);
227
239
  };
228
- const animateLargeTitle = (rootAnimation, rtl, backDirection, largeTitleEl, largeTitleBox, largeTitleTextBox, backButtonTextEl, backButtonTextBox) => {
240
+ const animateLargeTitle = (rootAnimation, rtl, backDirection, largeTitleEl, largeTitleBox, largeTitleTextBox, backButtonBox, backButtonTextEl, backButtonTextBox) => {
229
241
  var _a, _b;
230
242
  /**
231
243
  * The horizontal transform origin for the large title
@@ -245,52 +257,67 @@ const animateLargeTitle = (rootAnimation, rtl, backDirection, largeTitleEl, larg
245
257
  * title and the back button due to padding and font weight.
246
258
  */
247
259
  const LARGE_TITLE_TRANSLATION_OFFSET = 8;
260
+ let END_TRANSLATE_X = rtl
261
+ ? `-${window.innerWidth - backButtonBox.right - LARGE_TITLE_TRANSLATION_OFFSET}px`
262
+ : `${backButtonBox.x + LARGE_TITLE_TRANSLATION_OFFSET}px`;
248
263
  /**
249
- * The scaled title should (roughly) overlap the back button.
250
- * This ensures that the back button and title overlap during
251
- * the animation. Note that since both elements either fade in
252
- * or fade out over the course of the animation, neither element
253
- * will be fully visible on top of the other. As a result, the overlap
254
- * does not need to be perfect, so approximate values are acceptable here.
264
+ * How much to scale the large title up/down by.
255
265
  */
256
- const END_TRANSLATE_X = rtl
257
- ? `-${window.innerWidth - backButtonTextBox.right - LARGE_TITLE_TRANSLATION_OFFSET}px`
258
- : `${backButtonTextBox.x - LARGE_TITLE_TRANSLATION_OFFSET}px`;
266
+ let HEIGHT_SCALE = 0.5;
259
267
  /**
260
- * The top of the scaled large title
261
- * should match with the top of the
262
- * back button text element.
263
- * We subtract 2px to account for the top padding
264
- * on the large title element.
268
+ * The large title always starts full size.
265
269
  */
266
- const LARGE_TITLE_TOP_PADDING = 2;
267
- const END_TRANSLATE_Y = `${backButtonTextBox.y - LARGE_TITLE_TOP_PADDING}px`;
270
+ const START_SCALE = 'scale(1)';
268
271
  /**
269
- * In the forward direction, the large title should start at its
270
- * normal size and then scale down to be (roughly) the size of the
271
- * back button on the other view. In the backward direction, the
272
- * large title should start at (roughly) the size of the back button
273
- * and then scale up to its original size.
274
- *
275
- * Note that since both elements either fade in
276
- * or fade out over the course of the animation, neither element
277
- * will be fully visible on top of the other. As a result, the overlap
278
- * does not need to be perfect, so approximate values are acceptable here.
272
+ * By default, we don't worry about having the large title scaled to perfectly
273
+ * match the back button because we don't know if the back button's text matches
274
+ * the large title's text.
279
275
  */
276
+ let END_SCALE = `scale(${HEIGHT_SCALE})`;
277
+ // Text element not rendered if developers pass text="" to the back button
278
+ if (backButtonTextEl && backButtonTextBox) {
279
+ /**
280
+ * The scaled title should (roughly) overlap the back button. This ensures that
281
+ * the back button and title overlap during the animation. Note that since both
282
+ * elements either fade in or fade out over the course of the animation, neither
283
+ * element will be fully visible on top of the other. As a result, the overlap
284
+ * does not need to be perfect, so approximate values are acceptable here.
285
+ */
286
+ END_TRANSLATE_X = rtl
287
+ ? `-${window.innerWidth - backButtonTextBox.right - LARGE_TITLE_TRANSLATION_OFFSET}px`
288
+ : `${backButtonTextBox.x - LARGE_TITLE_TRANSLATION_OFFSET}px`;
289
+ /**
290
+ * In the forward direction, the large title should start at its normal size and
291
+ * then scale down to be (roughly) the size of the back button on the other view.
292
+ * In the backward direction, the large title should start at (roughly) the size
293
+ * of the back button and then scale up to its original size.
294
+ * Note that since both elements either fade in or fade out over the course of the
295
+ * animation, neither element will be fully visible on top of the other. As a result,
296
+ * the overlap does not need to be perfect, so approximate values are acceptable here.
297
+ */
298
+ /**
299
+ * When the title and back button texts match then they should overlap during the
300
+ * page transition. If the texts do not match up then the large title text scale
301
+ * adjusts to not perfectly match the back button text otherwise the proportions
302
+ * will be incorrect. When the texts match we scale both the width and height to
303
+ * account for font weight differences between the title and back button.
304
+ */
305
+ const doTitleAndButtonTextsMatch = ((_a = backButtonTextEl.textContent) === null || _a === void 0 ? void 0 : _a.trim()) === ((_b = largeTitleEl.textContent) === null || _b === void 0 ? void 0 : _b.trim());
306
+ const WIDTH_SCALE = backButtonTextBox.width / largeTitleTextBox.width;
307
+ HEIGHT_SCALE = backButtonTextBox.height / (largeTitleTextBox.height - LARGE_TITLE_SIZE_OFFSET);
308
+ /**
309
+ * Even though we set TEXT_START_SCALE to HEIGHT_SCALE above, we potentially need
310
+ * to re-compute this here since the HEIGHT_SCALE may have changed.
311
+ */
312
+ END_SCALE = doTitleAndButtonTextsMatch ? `scale(${WIDTH_SCALE}, ${HEIGHT_SCALE})` : `scale(${HEIGHT_SCALE})`;
313
+ }
280
314
  /**
281
- * When the title and back button texts match
282
- * then they should overlap during the page transition.
283
- * If the texts do not match up then the large title text scale adjusts
284
- * to not perfectly match the back button text otherwise the
285
- * proportions will be incorrect.
286
- * When the texts match we scale both the width and height to account for
287
- * font weight differences between the title and back button.
315
+ * The midpoints of the back button and the title should align such that the back
316
+ * button and title appear to be centered with each other.
288
317
  */
289
- const doTitleAndButtonTextsMatch = ((_a = backButtonTextEl.textContent) === null || _a === void 0 ? void 0 : _a.trim()) === ((_b = largeTitleEl.textContent) === null || _b === void 0 ? void 0 : _b.trim());
290
- const WIDTH_SCALE = backButtonTextBox.width / largeTitleTextBox.width;
291
- const HEIGHT_SCALE = backButtonTextBox.height / (largeTitleTextBox.height - LARGE_TITLE_SIZE_OFFSET);
292
- const START_SCALE = 'scale(1)';
293
- const END_SCALE = doTitleAndButtonTextsMatch ? `scale(${WIDTH_SCALE}, ${HEIGHT_SCALE})` : `scale(${HEIGHT_SCALE})`;
318
+ const backButtonMidPoint = backButtonBox.top + backButtonBox.height / 2;
319
+ const titleMidPoint = (largeTitleBox.height * HEIGHT_SCALE) / 2;
320
+ const END_TRANSLATE_Y = `${backButtonMidPoint - titleMidPoint}px`;
294
321
  const BACKWARDS_KEYFRAMES = [
295
322
  { offset: 0, opacity: 0, transform: `translate3d(${END_TRANSLATE_X}, ${END_TRANSLATE_Y}, 0) ${END_SCALE}` },
296
323
  { offset: 0.1, opacity: 0 },
@@ -12,8 +12,8 @@ const LIFECYCLE_WILL_LEAVE = 'ionViewWillLeave';
12
12
  const LIFECYCLE_DID_LEAVE = 'ionViewDidLeave';
13
13
  const LIFECYCLE_WILL_UNLOAD = 'ionViewWillUnload';
14
14
 
15
- const iosTransitionAnimation = () => Promise.resolve().then(function () { return require('./ios.transition-2b4db49c.js'); });
16
- const mdTransitionAnimation = () => Promise.resolve().then(function () { return require('./md.transition-8f3e1081.js'); });
15
+ const iosTransitionAnimation = () => Promise.resolve().then(function () { return require('./ios.transition-59b0e1d9.js'); });
16
+ const mdTransitionAnimation = () => Promise.resolve().then(function () { return require('./md.transition-0cc7c831.js'); });
17
17
  // TODO(FW-2832): types
18
18
  const transition = (opts) => {
19
19
  return new Promise((resolve, reject) => {
@@ -6,9 +6,9 @@
6
6
  Object.defineProperty(exports, '__esModule', { value: true });
7
7
 
8
8
  const animation = require('./animation-b4fdf128.js');
9
- const index = require('./index-1a575e52.js');
10
- const ios_transition = require('./ios.transition-2b4db49c.js');
11
- const md_transition = require('./md.transition-8f3e1081.js');
9
+ const index = require('./index-6047957b.js');
10
+ const ios_transition = require('./ios.transition-59b0e1d9.js');
11
+ const md_transition = require('./md.transition-0cc7c831.js');
12
12
  const cubicBezier = require('./cubic-bezier-f2dccc53.js');
13
13
  const index$1 = require('./index-ee07ed59.js');
14
14
  const ionicGlobal = require('./ionic-global-35b86a09.js');
@@ -17,7 +17,7 @@ const keyboardController = require('./keyboard-controller-c05e747a.js');
17
17
  const cubicBezier = require('./cubic-bezier-f2dccc53.js');
18
18
  const frameworkDelegate = require('./framework-delegate-55f5683a.js');
19
19
  const lockController = require('./lock-controller-6585a42a.js');
20
- const index$3 = require('./index-1a575e52.js');
20
+ const index$3 = require('./index-6047957b.js');
21
21
  require('./index-c8d52405.js');
22
22
  require('./keyboard-0272231f.js');
23
23
  require('./capacitor-c04564bf.js');
@@ -14,7 +14,7 @@ const index$4 = require('./index-5915f9b3.js');
14
14
  const capacitor = require('./capacitor-c04564bf.js');
15
15
  const overlays = require('./overlays-2feabb85.js');
16
16
  const theme = require('./theme-d1c573d2.js');
17
- const index$5 = require('./index-1a575e52.js');
17
+ const index$5 = require('./index-6047957b.js');
18
18
  const ionicGlobal = require('./ionic-global-35b86a09.js');
19
19
  const keyboard = require('./keyboard-af1bb365.js');
20
20
  const animation = require('./animation-b4fdf128.js');
@@ -8,7 +8,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
8
8
  const index = require('./index-8709af32.js');
9
9
  const cubicBezier = require('./cubic-bezier-f2dccc53.js');
10
10
  const helpers = require('./helpers-afaa9001.js');
11
- const index$1 = require('./index-1a575e52.js');
11
+ const index$1 = require('./index-6047957b.js');
12
12
  const ionicGlobal = require('./ionic-global-35b86a09.js');
13
13
  const frameworkDelegate = require('./framework-delegate-55f5683a.js');
14
14
 
@@ -13,7 +13,7 @@ const lockController = require('./lock-controller-6585a42a.js');
13
13
  const index$1 = require('./index-5915f9b3.js');
14
14
  const ionicGlobal = require('./ionic-global-35b86a09.js');
15
15
  const theme = require('./theme-d1c573d2.js');
16
- const index$2 = require('./index-1a575e52.js');
16
+ const index$2 = require('./index-6047957b.js');
17
17
  const animation = require('./animation-b4fdf128.js');
18
18
  require('./index-c8d52405.js');
19
19
  require('./hardware-back-button-ed931127.js');
@@ -4,7 +4,7 @@
4
4
  'use strict';
5
5
 
6
6
  const animation = require('./animation-b4fdf128.js');
7
- const index = require('./index-1a575e52.js');
7
+ const index = require('./index-6047957b.js');
8
8
  require('./index-c8d52405.js');
9
9
  require('./index-8709af32.js');
10
10
  require('./helpers-afaa9001.js');
@@ -61,20 +61,22 @@ const createLargeTitleTransition = (rootAnimation, rtl, backDirection, enteringE
61
61
  const leavingLargeTitleBox = leavingLargeTitle.getBoundingClientRect();
62
62
  const enteringBackButtonBox = enteringBackButton.getBoundingClientRect();
63
63
  const enteringBackButtonTextEl = shadow(enteringBackButton).querySelector('.button-text');
64
- const enteringBackButtonTextBox = enteringBackButtonTextEl.getBoundingClientRect();
64
+ // Text element not rendered if developers pass text="" to the back button
65
+ const enteringBackButtonTextBox = enteringBackButtonTextEl === null || enteringBackButtonTextEl === void 0 ? void 0 : enteringBackButtonTextEl.getBoundingClientRect();
65
66
  const leavingLargeTitleTextEl = shadow(leavingLargeTitle).querySelector('.toolbar-title');
66
67
  const leavingLargeTitleTextBox = leavingLargeTitleTextEl.getBoundingClientRect();
67
- animateLargeTitle(rootAnimation, rtl, backDirection, leavingLargeTitle, leavingLargeTitleBox, leavingLargeTitleTextBox, enteringBackButtonTextEl, enteringBackButtonTextBox);
68
+ animateLargeTitle(rootAnimation, rtl, backDirection, leavingLargeTitle, leavingLargeTitleBox, leavingLargeTitleTextBox, enteringBackButtonBox, enteringBackButtonTextEl, enteringBackButtonTextBox);
68
69
  animateBackButton(rootAnimation, rtl, backDirection, enteringBackButton, enteringBackButtonBox, enteringBackButtonTextEl, enteringBackButtonTextBox, leavingLargeTitle, leavingLargeTitleTextBox);
69
70
  }
70
71
  else if (shouldAnimationBackward) {
71
72
  const enteringLargeTitleBox = enteringLargeTitle.getBoundingClientRect();
72
73
  const leavingBackButtonBox = leavingBackButton.getBoundingClientRect();
73
74
  const leavingBackButtonTextEl = shadow(leavingBackButton).querySelector('.button-text');
74
- const leavingBackButtonTextBox = leavingBackButtonTextEl.getBoundingClientRect();
75
+ // Text element not rendered if developers pass text="" to the back button
76
+ const leavingBackButtonTextBox = leavingBackButtonTextEl === null || leavingBackButtonTextEl === void 0 ? void 0 : leavingBackButtonTextEl.getBoundingClientRect();
75
77
  const enteringLargeTitleTextEl = shadow(enteringLargeTitle).querySelector('.toolbar-title');
76
78
  const enteringLargeTitleTextBox = enteringLargeTitleTextEl.getBoundingClientRect();
77
- animateLargeTitle(rootAnimation, rtl, backDirection, enteringLargeTitle, enteringLargeTitleBox, enteringLargeTitleTextBox, leavingBackButtonTextEl, leavingBackButtonTextBox);
79
+ animateLargeTitle(rootAnimation, rtl, backDirection, enteringLargeTitle, enteringLargeTitleBox, enteringLargeTitleTextBox, leavingBackButtonBox, leavingBackButtonTextEl, leavingBackButtonTextBox);
78
80
  animateBackButton(rootAnimation, rtl, backDirection, leavingBackButton, leavingBackButtonBox, leavingBackButtonTextEl, leavingBackButtonTextBox, enteringLargeTitle, enteringLargeTitleTextBox);
79
81
  }
80
82
  return {
@@ -88,26 +90,31 @@ const animateBackButton = (rootAnimation, rtl, backDirection, backButtonEl, back
88
90
  const TEXT_ORIGIN_X = rtl ? 'right' : 'left';
89
91
  const ICON_ORIGIN_X = rtl ? 'left' : 'right';
90
92
  const CONTAINER_ORIGIN_X = rtl ? 'right' : 'left';
91
- /**
92
- * When the title and back button texts match
93
- * then they should overlap during the page transition.
94
- * If the texts do not match up then the back button text scale adjusts
95
- * to not perfectly match the large title text otherwise the
96
- * proportions will be incorrect.
97
- * When the texts match we scale both the width and height to account for
98
- * font weight differences between the title and back button.
99
- */
100
- const doTitleAndButtonTextsMatch = ((_a = backButtonTextEl.textContent) === null || _a === void 0 ? void 0 : _a.trim()) === ((_b = largeTitleEl.textContent) === null || _b === void 0 ? void 0 : _b.trim());
101
- const WIDTH_SCALE = largeTitleTextBox.width / backButtonTextBox.width;
102
- /**
103
- * We subtract an offset to account for slight sizing/padding
104
- * differences between the title and the back button.
105
- */
106
- const HEIGHT_SCALE = (largeTitleTextBox.height - LARGE_TITLE_SIZE_OFFSET) / backButtonTextBox.height;
107
- const TEXT_START_SCALE = doTitleAndButtonTextsMatch
108
- ? `scale(${WIDTH_SCALE}, ${HEIGHT_SCALE})`
109
- : `scale(${HEIGHT_SCALE})`;
93
+ let WIDTH_SCALE = 1;
94
+ let HEIGHT_SCALE = 1;
95
+ let TEXT_START_SCALE = `scale(${HEIGHT_SCALE})`;
110
96
  const TEXT_END_SCALE = 'scale(1)';
97
+ if (backButtonTextEl && backButtonTextBox) {
98
+ /**
99
+ * When the title and back button texts match then they should overlap during the
100
+ * page transition. If the texts do not match up then the back button text scale
101
+ * adjusts to not perfectly match the large title text otherwise the proportions
102
+ * will be incorrect. When the texts match we scale both the width and height to
103
+ * account for font weight differences between the title and back button.
104
+ */
105
+ const doTitleAndButtonTextsMatch = ((_a = backButtonTextEl.textContent) === null || _a === void 0 ? void 0 : _a.trim()) === ((_b = largeTitleEl.textContent) === null || _b === void 0 ? void 0 : _b.trim());
106
+ WIDTH_SCALE = largeTitleTextBox.width / backButtonTextBox.width;
107
+ /**
108
+ * Subtract an offset to account for slight sizing/padding differences between the
109
+ * title and the back button.
110
+ */
111
+ HEIGHT_SCALE = (largeTitleTextBox.height - LARGE_TITLE_SIZE_OFFSET) / backButtonTextBox.height;
112
+ /**
113
+ * Even though we set TEXT_START_SCALE to HEIGHT_SCALE above, we potentially need
114
+ * to re-compute this here since the HEIGHT_SCALE may have changed.
115
+ */
116
+ TEXT_START_SCALE = doTitleAndButtonTextsMatch ? `scale(${WIDTH_SCALE}, ${HEIGHT_SCALE})` : `scale(${HEIGHT_SCALE})`;
117
+ }
111
118
  const backButtonIconEl = shadow(backButtonEl).querySelector('ion-icon');
112
119
  const backButtonIconBox = backButtonIconEl.getBoundingClientRect();
113
120
  /**
@@ -204,11 +211,11 @@ const animateBackButton = (rootAnimation, rtl, backDirection, backButtonEl, back
204
211
  top: '0px',
205
212
  [CONTAINER_ORIGIN_X]: '0px',
206
213
  })
207
- .keyframes(CONTAINER_KEYFRAMES);
208
- enteringBackButtonTextAnimation
209
- .beforeStyles({
210
- 'transform-origin': `${TEXT_ORIGIN_X} top`,
211
- })
214
+ /**
215
+ * The write hooks must be set on this animation as it is guaranteed to run. Other
216
+ * animations such as the back button text animation will not run if the back button
217
+ * has no visible text.
218
+ */
212
219
  .beforeAddWrite(() => {
213
220
  backButtonEl.style.setProperty('display', 'none');
214
221
  clonedBackButtonEl.style.setProperty(TEXT_ORIGIN_X, BACK_BUTTON_START_OFFSET);
@@ -217,6 +224,11 @@ const animateBackButton = (rootAnimation, rtl, backDirection, backButtonEl, back
217
224
  backButtonEl.style.setProperty('display', '');
218
225
  clonedBackButtonEl.style.setProperty('display', 'none');
219
226
  clonedBackButtonEl.style.removeProperty(TEXT_ORIGIN_X);
227
+ })
228
+ .keyframes(CONTAINER_KEYFRAMES);
229
+ enteringBackButtonTextAnimation
230
+ .beforeStyles({
231
+ 'transform-origin': `${TEXT_ORIGIN_X} top`,
220
232
  })
221
233
  .keyframes(TEXT_KEYFRAMES);
222
234
  enteringBackButtonIconAnimation
@@ -230,7 +242,7 @@ const animateBackButton = (rootAnimation, rtl, backDirection, backButtonEl, back
230
242
  enteringBackButtonAnimation,
231
243
  ]);
232
244
  };
233
- const animateLargeTitle = (rootAnimation, rtl, backDirection, largeTitleEl, largeTitleBox, largeTitleTextBox, backButtonTextEl, backButtonTextBox) => {
245
+ const animateLargeTitle = (rootAnimation, rtl, backDirection, largeTitleEl, largeTitleBox, largeTitleTextBox, backButtonBox, backButtonTextEl, backButtonTextBox) => {
234
246
  var _a, _b;
235
247
  /**
236
248
  * The horizontal transform origin for the large title
@@ -250,52 +262,67 @@ const animateLargeTitle = (rootAnimation, rtl, backDirection, largeTitleEl, larg
250
262
  * title and the back button due to padding and font weight.
251
263
  */
252
264
  const LARGE_TITLE_TRANSLATION_OFFSET = 8;
265
+ let END_TRANSLATE_X = rtl
266
+ ? `-${window.innerWidth - backButtonBox.right - LARGE_TITLE_TRANSLATION_OFFSET}px`
267
+ : `${backButtonBox.x + LARGE_TITLE_TRANSLATION_OFFSET}px`;
253
268
  /**
254
- * The scaled title should (roughly) overlap the back button.
255
- * This ensures that the back button and title overlap during
256
- * the animation. Note that since both elements either fade in
257
- * or fade out over the course of the animation, neither element
258
- * will be fully visible on top of the other. As a result, the overlap
259
- * does not need to be perfect, so approximate values are acceptable here.
269
+ * How much to scale the large title up/down by.
260
270
  */
261
- const END_TRANSLATE_X = rtl
262
- ? `-${window.innerWidth - backButtonTextBox.right - LARGE_TITLE_TRANSLATION_OFFSET}px`
263
- : `${backButtonTextBox.x - LARGE_TITLE_TRANSLATION_OFFSET}px`;
271
+ let HEIGHT_SCALE = 0.5;
264
272
  /**
265
- * The top of the scaled large title
266
- * should match with the top of the
267
- * back button text element.
268
- * We subtract 2px to account for the top padding
269
- * on the large title element.
273
+ * The large title always starts full size.
270
274
  */
271
- const LARGE_TITLE_TOP_PADDING = 2;
272
- const END_TRANSLATE_Y = `${backButtonTextBox.y - LARGE_TITLE_TOP_PADDING}px`;
275
+ const START_SCALE = 'scale(1)';
273
276
  /**
274
- * In the forward direction, the large title should start at its
275
- * normal size and then scale down to be (roughly) the size of the
276
- * back button on the other view. In the backward direction, the
277
- * large title should start at (roughly) the size of the back button
278
- * and then scale up to its original size.
279
- *
280
- * Note that since both elements either fade in
281
- * or fade out over the course of the animation, neither element
282
- * will be fully visible on top of the other. As a result, the overlap
283
- * does not need to be perfect, so approximate values are acceptable here.
277
+ * By default, we don't worry about having the large title scaled to perfectly
278
+ * match the back button because we don't know if the back button's text matches
279
+ * the large title's text.
284
280
  */
281
+ let END_SCALE = `scale(${HEIGHT_SCALE})`;
282
+ // Text element not rendered if developers pass text="" to the back button
283
+ if (backButtonTextEl && backButtonTextBox) {
284
+ /**
285
+ * The scaled title should (roughly) overlap the back button. This ensures that
286
+ * the back button and title overlap during the animation. Note that since both
287
+ * elements either fade in or fade out over the course of the animation, neither
288
+ * element will be fully visible on top of the other. As a result, the overlap
289
+ * does not need to be perfect, so approximate values are acceptable here.
290
+ */
291
+ END_TRANSLATE_X = rtl
292
+ ? `-${window.innerWidth - backButtonTextBox.right - LARGE_TITLE_TRANSLATION_OFFSET}px`
293
+ : `${backButtonTextBox.x - LARGE_TITLE_TRANSLATION_OFFSET}px`;
294
+ /**
295
+ * In the forward direction, the large title should start at its normal size and
296
+ * then scale down to be (roughly) the size of the back button on the other view.
297
+ * In the backward direction, the large title should start at (roughly) the size
298
+ * of the back button and then scale up to its original size.
299
+ * Note that since both elements either fade in or fade out over the course of the
300
+ * animation, neither element will be fully visible on top of the other. As a result,
301
+ * the overlap does not need to be perfect, so approximate values are acceptable here.
302
+ */
303
+ /**
304
+ * When the title and back button texts match then they should overlap during the
305
+ * page transition. If the texts do not match up then the large title text scale
306
+ * adjusts to not perfectly match the back button text otherwise the proportions
307
+ * will be incorrect. When the texts match we scale both the width and height to
308
+ * account for font weight differences between the title and back button.
309
+ */
310
+ const doTitleAndButtonTextsMatch = ((_a = backButtonTextEl.textContent) === null || _a === void 0 ? void 0 : _a.trim()) === ((_b = largeTitleEl.textContent) === null || _b === void 0 ? void 0 : _b.trim());
311
+ const WIDTH_SCALE = backButtonTextBox.width / largeTitleTextBox.width;
312
+ HEIGHT_SCALE = backButtonTextBox.height / (largeTitleTextBox.height - LARGE_TITLE_SIZE_OFFSET);
313
+ /**
314
+ * Even though we set TEXT_START_SCALE to HEIGHT_SCALE above, we potentially need
315
+ * to re-compute this here since the HEIGHT_SCALE may have changed.
316
+ */
317
+ END_SCALE = doTitleAndButtonTextsMatch ? `scale(${WIDTH_SCALE}, ${HEIGHT_SCALE})` : `scale(${HEIGHT_SCALE})`;
318
+ }
285
319
  /**
286
- * When the title and back button texts match
287
- * then they should overlap during the page transition.
288
- * If the texts do not match up then the large title text scale adjusts
289
- * to not perfectly match the back button text otherwise the
290
- * proportions will be incorrect.
291
- * When the texts match we scale both the width and height to account for
292
- * font weight differences between the title and back button.
320
+ * The midpoints of the back button and the title should align such that the back
321
+ * button and title appear to be centered with each other.
293
322
  */
294
- const doTitleAndButtonTextsMatch = ((_a = backButtonTextEl.textContent) === null || _a === void 0 ? void 0 : _a.trim()) === ((_b = largeTitleEl.textContent) === null || _b === void 0 ? void 0 : _b.trim());
295
- const WIDTH_SCALE = backButtonTextBox.width / largeTitleTextBox.width;
296
- const HEIGHT_SCALE = backButtonTextBox.height / (largeTitleTextBox.height - LARGE_TITLE_SIZE_OFFSET);
297
- const START_SCALE = 'scale(1)';
298
- const END_SCALE = doTitleAndButtonTextsMatch ? `scale(${WIDTH_SCALE}, ${HEIGHT_SCALE})` : `scale(${HEIGHT_SCALE})`;
323
+ const backButtonMidPoint = backButtonBox.top + backButtonBox.height / 2;
324
+ const titleMidPoint = (largeTitleBox.height * HEIGHT_SCALE) / 2;
325
+ const END_TRANSLATE_Y = `${backButtonMidPoint - titleMidPoint}px`;
299
326
  const BACKWARDS_KEYFRAMES = [
300
327
  { offset: 0, opacity: 0, transform: `translate3d(${END_TRANSLATE_X}, ${END_TRANSLATE_Y}, 0) ${END_SCALE}` },
301
328
  { offset: 0.1, opacity: 0 },
@@ -4,7 +4,7 @@
4
4
  'use strict';
5
5
 
6
6
  const animation = require('./animation-b4fdf128.js');
7
- const index = require('./index-1a575e52.js');
7
+ const index = require('./index-6047957b.js');
8
8
  require('./index-c8d52405.js');
9
9
  require('./index-8709af32.js');
10
10
  require('./helpers-afaa9001.js');