framer-motion 8.5.2-alpha.0 → 8.5.2-alpha.3

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.
package/dist/cjs/index.js CHANGED
@@ -90,7 +90,7 @@ function useVisualElement(Component, visualState, props, createVisualElement) {
90
90
  * So if we detect a situtation where optimised appear animations
91
91
  * are running, we use useLayoutEffect to trigger animations.
92
92
  */
93
- const useAnimateChangesEffect = window.MotionAppearAnimations
93
+ const useAnimateChangesEffect = window.HandoffAppearAnimations
94
94
  ? useIsomorphicLayoutEffect
95
95
  : React.useEffect;
96
96
  useAnimateChangesEffect(() => {
@@ -2105,7 +2105,7 @@ class MotionValue {
2105
2105
  * This will be replaced by the build step with the latest version number.
2106
2106
  * When MotionValues are provided to motion components, warn if versions are mixed.
2107
2107
  */
2108
- this.version = "8.5.2-alpha.0";
2108
+ this.version = "8.5.2-alpha.3";
2109
2109
  /**
2110
2110
  * Duration, in milliseconds, since last updating frame.
2111
2111
  *
@@ -2799,60 +2799,6 @@ function isWillChangeMotionValue(value) {
2799
2799
  return Boolean(isMotionValue(value) && value.add);
2800
2800
  }
2801
2801
 
2802
- const appearStoreId = (id, value) => `${id}: ${value}`;
2803
-
2804
- function handoffOptimizedAppearAnimation(id, name, value) {
2805
- const { MotionAppearAnimations } = window;
2806
- const animationId = appearStoreId(id, transformProps.has(name) ? "transform" : name);
2807
- const { animation, ready } = (MotionAppearAnimations && MotionAppearAnimations.get(animationId)) ||
2808
- {};
2809
- if (!animation)
2810
- return 0;
2811
- const cancelOptimisedAnimation = () => {
2812
- MotionAppearAnimations.delete(animationId);
2813
- /**
2814
- * Animation.cancel() throws so it needs to be wrapped in a try/catch
2815
- */
2816
- try {
2817
- animation.cancel();
2818
- }
2819
- catch (e) { }
2820
- };
2821
- if (ready) {
2822
- const sampledTime = performance.now();
2823
- /**
2824
- * Resync handoff animation with optimised animation.
2825
- *
2826
- * This step would be unnecessary if we triggered animateChanges() in useEffect,
2827
- * but due to potential hydration errors we currently fire them in useLayoutEffect.
2828
- *
2829
- * By the time we're safely ready to cancel the optimised WAAPI animation,
2830
- * the main thread might have been blocked and desynced the two animations.
2831
- *
2832
- * Here, we resync the two animations before the optimised WAAPI animation is cancelled.
2833
- */
2834
- sync.update(() => {
2835
- if (value.animation) {
2836
- value.animation.currentTime = performance.now() - sampledTime;
2837
- }
2838
- });
2839
- /**
2840
- * We allow the animation to persist until the next frame:
2841
- * 1. So it continues to play until Framer Motion is ready to render
2842
- * (avoiding a potential flash of the element's original state)
2843
- * 2. As all independent transforms share a single transform animation, stopping
2844
- * it synchronously would prevent subsequent transforms from handing off.
2845
- */
2846
- sync.render(cancelOptimisedAnimation);
2847
- console.log(animation.currentTime);
2848
- return animation.currentTime || 0;
2849
- }
2850
- else {
2851
- cancelOptimisedAnimation();
2852
- return 0;
2853
- }
2854
- }
2855
-
2856
2802
  const optimizedAppearDataId = "framerAppearId";
2857
2803
  const optimizedAppearDataAttribute = "data-" + camelToDash(optimizedAppearDataId);
2858
2804
 
@@ -4254,10 +4200,10 @@ function animateTarget(visualElement, definition, { delay = 0, transitionOverrid
4254
4200
  * If this is the first time a value is being animated, check
4255
4201
  * to see if we're handling off from an existing animation.
4256
4202
  */
4257
- if (!value.hasAnimated) {
4203
+ if (!value.hasAnimated && window.HandoffAppearAnimations) {
4258
4204
  const appearId = visualElement.getProps()[optimizedAppearDataAttribute];
4259
4205
  if (appearId) {
4260
- valueTransition.elapsed = handoffOptimizedAppearAnimation(appearId, key, value);
4206
+ valueTransition.elapsed = window.HandoffAppearAnimations(appearId, key, value, sync);
4261
4207
  }
4262
4208
  }
4263
4209
  let animation = value.start(createMotionValueAnimation(key, value, valueTarget, visualElement.shouldReduceMotion && transformProps.has(key)
@@ -6007,7 +5953,7 @@ function updateMotionValuesFromProps(element, next, prev) {
6007
5953
  * and warn against mismatches.
6008
5954
  */
6009
5955
  if (process.env.NODE_ENV === "development") {
6010
- warnOnce(nextValue.version === "8.5.2-alpha.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.5.2-alpha.0 may not work as expected.`);
5956
+ warnOnce(nextValue.version === "8.5.2-alpha.3", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.5.2-alpha.3 may not work as expected.`);
6011
5957
  }
6012
5958
  }
6013
5959
  else if (isMotionValue(prevValue)) {
@@ -9869,11 +9815,73 @@ function useResetProjection() {
9869
9815
  return reset;
9870
9816
  }
9871
9817
 
9818
+ const appearStoreId = (id, value) => `${id}: ${value}`;
9819
+
9820
+ const appearAnimationStore = new Map();
9821
+
9822
+ function handoffOptimizedAppearAnimation(id, name, value,
9823
+ /**
9824
+ * This function is loaded via window by startOptimisedAnimation.
9825
+ * By accepting `sync` as an argument, rather than using it via
9826
+ * import, it can be kept out of the first-load Framer bundle,
9827
+ * while also allowing this function to not be included in
9828
+ * Framer Motion bundles where it's not needed.
9829
+ */
9830
+ sync) {
9831
+ const storeId = appearStoreId(id, transformProps.has(name) ? "transform" : name);
9832
+ const { animation, ready } = appearAnimationStore.get(storeId) || {};
9833
+ if (!animation)
9834
+ return 0;
9835
+ const cancelOptimisedAnimation = () => {
9836
+ appearAnimationStore.delete(storeId);
9837
+ /**
9838
+ * Animation.cancel() throws so it needs to be wrapped in a try/catch
9839
+ */
9840
+ try {
9841
+ animation.cancel();
9842
+ }
9843
+ catch (e) { }
9844
+ };
9845
+ if (ready) {
9846
+ const sampledTime = performance.now();
9847
+ /**
9848
+ * Resync handoff animation with optimised animation.
9849
+ *
9850
+ * This step would be unnecessary if we triggered animateChanges() in useEffect,
9851
+ * but due to potential hydration errors we currently fire them in useLayoutEffect.
9852
+ *
9853
+ * By the time we're safely ready to cancel the optimised WAAPI animation,
9854
+ * the main thread might have been blocked and desynced the two animations.
9855
+ *
9856
+ * Here, we resync the two animations before the optimised WAAPI animation is cancelled.
9857
+ */
9858
+ sync.update(() => {
9859
+ if (value.animation) {
9860
+ value.animation.currentTime = performance.now() - sampledTime;
9861
+ }
9862
+ });
9863
+ /**
9864
+ * We allow the animation to persist until the next frame:
9865
+ * 1. So it continues to play until Framer Motion is ready to render
9866
+ * (avoiding a potential flash of the element's original state)
9867
+ * 2. As all independent transforms share a single transform animation, stopping
9868
+ * it synchronously would prevent subsequent transforms from handing off.
9869
+ */
9870
+ sync.render(cancelOptimisedAnimation);
9871
+ console.log("handing off from", animation.currentTime);
9872
+ return animation.currentTime || 0;
9873
+ }
9874
+ else {
9875
+ cancelOptimisedAnimation();
9876
+ return 0;
9877
+ }
9878
+ }
9879
+
9872
9880
  function startOptimizedAppearAnimation(element, name, keyframes, options, onReady) {
9873
- window.MotionAppearAnimations || (window.MotionAppearAnimations = new Map());
9874
9881
  const id = element.dataset[optimizedAppearDataId];
9875
9882
  if (!id)
9876
9883
  return;
9884
+ window.HandoffAppearAnimations = handoffOptimizedAppearAnimation;
9877
9885
  const storeId = appearStoreId(id, name);
9878
9886
  /**
9879
9887
  * Use a dummy animation to detect when Chrome is ready to start
@@ -9881,15 +9889,20 @@ function startOptimizedAppearAnimation(element, name, keyframes, options, onRead
9881
9889
  * until then.
9882
9890
  */
9883
9891
  const readyAnimation = animateStyle(element, name, [keyframes[0], keyframes[0]], { duration: 1 });
9884
- window.MotionAppearAnimations.set(storeId, {
9892
+ appearAnimationStore.set(storeId, {
9885
9893
  animation: readyAnimation,
9886
9894
  ready: false,
9887
9895
  });
9888
9896
  const startAnimation = () => {
9889
- const animation = animateStyle(element, name, keyframes, options);
9890
- window.MotionAppearAnimations.set(storeId, { animation, ready: true });
9897
+ var _a;
9898
+ const appearAnimation = animateStyle(element, name, keyframes, options);
9899
+ const current = (_a = document.timeline) === null || _a === void 0 ? void 0 : _a.currentTime;
9900
+ if (current) {
9901
+ appearAnimation.startTime = current;
9902
+ }
9903
+ appearAnimationStore.set(storeId, { animation: appearAnimation, ready: true });
9891
9904
  if (onReady)
9892
- onReady(animation);
9905
+ onReady(appearAnimation);
9893
9906
  };
9894
9907
  if (readyAnimation.ready) {
9895
9908
  readyAnimation.ready.then(() => {
@@ -1,16 +1,22 @@
1
- import { sync } from '../../frameloop/index.mjs';
2
1
  import { transformProps } from '../../render/html/utils/transform.mjs';
2
+ import { appearAnimationStore } from './store.mjs';
3
3
  import { appearStoreId } from './store-id.mjs';
4
4
 
5
- function handoffOptimizedAppearAnimation(id, name, value) {
6
- const { MotionAppearAnimations } = window;
7
- const animationId = appearStoreId(id, transformProps.has(name) ? "transform" : name);
8
- const { animation, ready } = (MotionAppearAnimations && MotionAppearAnimations.get(animationId)) ||
9
- {};
5
+ function handoffOptimizedAppearAnimation(id, name, value,
6
+ /**
7
+ * This function is loaded via window by startOptimisedAnimation.
8
+ * By accepting `sync` as an argument, rather than using it via
9
+ * import, it can be kept out of the first-load Framer bundle,
10
+ * while also allowing this function to not be included in
11
+ * Framer Motion bundles where it's not needed.
12
+ */
13
+ sync) {
14
+ const storeId = appearStoreId(id, transformProps.has(name) ? "transform" : name);
15
+ const { animation, ready } = appearAnimationStore.get(storeId) || {};
10
16
  if (!animation)
11
17
  return 0;
12
18
  const cancelOptimisedAnimation = () => {
13
- MotionAppearAnimations.delete(animationId);
19
+ appearAnimationStore.delete(storeId);
14
20
  /**
15
21
  * Animation.cancel() throws so it needs to be wrapped in a try/catch
16
22
  */
@@ -45,7 +51,7 @@ function handoffOptimizedAppearAnimation(id, name, value) {
45
51
  * it synchronously would prevent subsequent transforms from handing off.
46
52
  */
47
53
  sync.render(cancelOptimisedAnimation);
48
- console.log(animation.currentTime);
54
+ console.log("handing off from", animation.currentTime);
49
55
  return animation.currentTime || 0;
50
56
  }
51
57
  else {
@@ -1,12 +1,14 @@
1
1
  import { appearStoreId } from './store-id.mjs';
2
2
  import { animateStyle } from '../waapi/index.mjs';
3
3
  import { optimizedAppearDataId } from './data-id.mjs';
4
+ import { handoffOptimizedAppearAnimation } from './handoff.mjs';
5
+ import { appearAnimationStore } from './store.mjs';
4
6
 
5
7
  function startOptimizedAppearAnimation(element, name, keyframes, options, onReady) {
6
- window.MotionAppearAnimations || (window.MotionAppearAnimations = new Map());
7
8
  const id = element.dataset[optimizedAppearDataId];
8
9
  if (!id)
9
10
  return;
11
+ window.HandoffAppearAnimations = handoffOptimizedAppearAnimation;
10
12
  const storeId = appearStoreId(id, name);
11
13
  /**
12
14
  * Use a dummy animation to detect when Chrome is ready to start
@@ -14,15 +16,20 @@ function startOptimizedAppearAnimation(element, name, keyframes, options, onRead
14
16
  * until then.
15
17
  */
16
18
  const readyAnimation = animateStyle(element, name, [keyframes[0], keyframes[0]], { duration: 1 });
17
- window.MotionAppearAnimations.set(storeId, {
19
+ appearAnimationStore.set(storeId, {
18
20
  animation: readyAnimation,
19
21
  ready: false,
20
22
  });
21
23
  const startAnimation = () => {
22
- const animation = animateStyle(element, name, keyframes, options);
23
- window.MotionAppearAnimations.set(storeId, { animation, ready: true });
24
+ var _a;
25
+ const appearAnimation = animateStyle(element, name, keyframes, options);
26
+ const current = (_a = document.timeline) === null || _a === void 0 ? void 0 : _a.currentTime;
27
+ if (current) {
28
+ appearAnimation.startTime = current;
29
+ }
30
+ appearAnimationStore.set(storeId, { animation: appearAnimation, ready: true });
24
31
  if (onReady)
25
- onReady(animation);
32
+ onReady(appearAnimation);
26
33
  };
27
34
  if (readyAnimation.ready) {
28
35
  readyAnimation.ready.then(() => {
@@ -0,0 +1,3 @@
1
+ const appearAnimationStore = new Map();
2
+
3
+ export { appearAnimationStore };
@@ -41,7 +41,7 @@ function useVisualElement(Component, visualState, props, createVisualElement) {
41
41
  * So if we detect a situtation where optimised appear animations
42
42
  * are running, we use useLayoutEffect to trigger animations.
43
43
  */
44
- const useAnimateChangesEffect = window.MotionAppearAnimations
44
+ const useAnimateChangesEffect = window.HandoffAppearAnimations
45
45
  ? useIsomorphicLayoutEffect
46
46
  : useEffect;
47
47
  useAnimateChangesEffect(() => {
@@ -2,9 +2,9 @@ import { setTarget } from './setters.mjs';
2
2
  import { resolveVariant } from './resolve-dynamic-variants.mjs';
3
3
  import { transformProps } from '../html/utils/transform.mjs';
4
4
  import { isWillChangeMotionValue } from '../../value/use-will-change/is.mjs';
5
- import { handoffOptimizedAppearAnimation } from '../../animation/optimized-appear/handoff.mjs';
6
5
  import { optimizedAppearDataAttribute } from '../../animation/optimized-appear/data-id.mjs';
7
6
  import { createMotionValueAnimation } from '../../animation/index.mjs';
7
+ import { sync } from '../../frameloop/index.mjs';
8
8
 
9
9
  function animateVisualElement(visualElement, definition, options = {}) {
10
10
  visualElement.notify("AnimationStart", definition);
@@ -88,10 +88,10 @@ function animateTarget(visualElement, definition, { delay = 0, transitionOverrid
88
88
  * If this is the first time a value is being animated, check
89
89
  * to see if we're handling off from an existing animation.
90
90
  */
91
- if (!value.hasAnimated) {
91
+ if (!value.hasAnimated && window.HandoffAppearAnimations) {
92
92
  const appearId = visualElement.getProps()[optimizedAppearDataAttribute];
93
93
  if (appearId) {
94
- valueTransition.elapsed = handoffOptimizedAppearAnimation(appearId, key, value);
94
+ valueTransition.elapsed = window.HandoffAppearAnimations(appearId, key, value, sync);
95
95
  }
96
96
  }
97
97
  let animation = value.start(createMotionValueAnimation(key, value, valueTarget, visualElement.shouldReduceMotion && transformProps.has(key)
@@ -22,7 +22,7 @@ function updateMotionValuesFromProps(element, next, prev) {
22
22
  * and warn against mismatches.
23
23
  */
24
24
  if (process.env.NODE_ENV === "development") {
25
- warnOnce(nextValue.version === "8.5.2-alpha.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.5.2-alpha.0 may not work as expected.`);
25
+ warnOnce(nextValue.version === "8.5.2-alpha.3", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.5.2-alpha.3 may not work as expected.`);
26
26
  }
27
27
  }
28
28
  else if (isMotionValue(prevValue)) {
@@ -25,7 +25,7 @@ class MotionValue {
25
25
  * This will be replaced by the build step with the latest version number.
26
26
  * When MotionValues are provided to motion components, warn if versions are mixed.
27
27
  */
28
- this.version = "8.5.2-alpha.0";
28
+ this.version = "8.5.2-alpha.3";
29
29
  /**
30
30
  * Duration, in milliseconds, since last updating frame.
31
31
  *
@@ -88,7 +88,7 @@
88
88
  * So if we detect a situtation where optimised appear animations
89
89
  * are running, we use useLayoutEffect to trigger animations.
90
90
  */
91
- const useAnimateChangesEffect = window.MotionAppearAnimations
91
+ const useAnimateChangesEffect = window.HandoffAppearAnimations
92
92
  ? useIsomorphicLayoutEffect
93
93
  : React.useEffect;
94
94
  useAnimateChangesEffect(() => {
@@ -2103,7 +2103,7 @@
2103
2103
  * This will be replaced by the build step with the latest version number.
2104
2104
  * When MotionValues are provided to motion components, warn if versions are mixed.
2105
2105
  */
2106
- this.version = "8.5.2-alpha.0";
2106
+ this.version = "8.5.2-alpha.3";
2107
2107
  /**
2108
2108
  * Duration, in milliseconds, since last updating frame.
2109
2109
  *
@@ -2797,60 +2797,6 @@
2797
2797
  return Boolean(isMotionValue(value) && value.add);
2798
2798
  }
2799
2799
 
2800
- const appearStoreId = (id, value) => `${id}: ${value}`;
2801
-
2802
- function handoffOptimizedAppearAnimation(id, name, value) {
2803
- const { MotionAppearAnimations } = window;
2804
- const animationId = appearStoreId(id, transformProps.has(name) ? "transform" : name);
2805
- const { animation, ready } = (MotionAppearAnimations && MotionAppearAnimations.get(animationId)) ||
2806
- {};
2807
- if (!animation)
2808
- return 0;
2809
- const cancelOptimisedAnimation = () => {
2810
- MotionAppearAnimations.delete(animationId);
2811
- /**
2812
- * Animation.cancel() throws so it needs to be wrapped in a try/catch
2813
- */
2814
- try {
2815
- animation.cancel();
2816
- }
2817
- catch (e) { }
2818
- };
2819
- if (ready) {
2820
- const sampledTime = performance.now();
2821
- /**
2822
- * Resync handoff animation with optimised animation.
2823
- *
2824
- * This step would be unnecessary if we triggered animateChanges() in useEffect,
2825
- * but due to potential hydration errors we currently fire them in useLayoutEffect.
2826
- *
2827
- * By the time we're safely ready to cancel the optimised WAAPI animation,
2828
- * the main thread might have been blocked and desynced the two animations.
2829
- *
2830
- * Here, we resync the two animations before the optimised WAAPI animation is cancelled.
2831
- */
2832
- sync.update(() => {
2833
- if (value.animation) {
2834
- value.animation.currentTime = performance.now() - sampledTime;
2835
- }
2836
- });
2837
- /**
2838
- * We allow the animation to persist until the next frame:
2839
- * 1. So it continues to play until Framer Motion is ready to render
2840
- * (avoiding a potential flash of the element's original state)
2841
- * 2. As all independent transforms share a single transform animation, stopping
2842
- * it synchronously would prevent subsequent transforms from handing off.
2843
- */
2844
- sync.render(cancelOptimisedAnimation);
2845
- console.log(animation.currentTime);
2846
- return animation.currentTime || 0;
2847
- }
2848
- else {
2849
- cancelOptimisedAnimation();
2850
- return 0;
2851
- }
2852
- }
2853
-
2854
2800
  const optimizedAppearDataId = "framerAppearId";
2855
2801
  const optimizedAppearDataAttribute = "data-" + camelToDash(optimizedAppearDataId);
2856
2802
 
@@ -4267,10 +4213,10 @@
4267
4213
  * If this is the first time a value is being animated, check
4268
4214
  * to see if we're handling off from an existing animation.
4269
4215
  */
4270
- if (!value.hasAnimated) {
4216
+ if (!value.hasAnimated && window.HandoffAppearAnimations) {
4271
4217
  const appearId = visualElement.getProps()[optimizedAppearDataAttribute];
4272
4218
  if (appearId) {
4273
- valueTransition.elapsed = handoffOptimizedAppearAnimation(appearId, key, value);
4219
+ valueTransition.elapsed = window.HandoffAppearAnimations(appearId, key, value, sync);
4274
4220
  }
4275
4221
  }
4276
4222
  let animation = value.start(createMotionValueAnimation(key, value, valueTarget, visualElement.shouldReduceMotion && transformProps.has(key)
@@ -6020,7 +5966,7 @@
6020
5966
  * and warn against mismatches.
6021
5967
  */
6022
5968
  {
6023
- warnOnce(nextValue.version === "8.5.2-alpha.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.5.2-alpha.0 may not work as expected.`);
5969
+ warnOnce(nextValue.version === "8.5.2-alpha.3", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.5.2-alpha.3 may not work as expected.`);
6024
5970
  }
6025
5971
  }
6026
5972
  else if (isMotionValue(prevValue)) {
@@ -10488,11 +10434,73 @@
10488
10434
  return reset;
10489
10435
  }
10490
10436
 
10437
+ const appearStoreId = (id, value) => `${id}: ${value}`;
10438
+
10439
+ const appearAnimationStore = new Map();
10440
+
10441
+ function handoffOptimizedAppearAnimation(id, name, value,
10442
+ /**
10443
+ * This function is loaded via window by startOptimisedAnimation.
10444
+ * By accepting `sync` as an argument, rather than using it via
10445
+ * import, it can be kept out of the first-load Framer bundle,
10446
+ * while also allowing this function to not be included in
10447
+ * Framer Motion bundles where it's not needed.
10448
+ */
10449
+ sync) {
10450
+ const storeId = appearStoreId(id, transformProps.has(name) ? "transform" : name);
10451
+ const { animation, ready } = appearAnimationStore.get(storeId) || {};
10452
+ if (!animation)
10453
+ return 0;
10454
+ const cancelOptimisedAnimation = () => {
10455
+ appearAnimationStore.delete(storeId);
10456
+ /**
10457
+ * Animation.cancel() throws so it needs to be wrapped in a try/catch
10458
+ */
10459
+ try {
10460
+ animation.cancel();
10461
+ }
10462
+ catch (e) { }
10463
+ };
10464
+ if (ready) {
10465
+ const sampledTime = performance.now();
10466
+ /**
10467
+ * Resync handoff animation with optimised animation.
10468
+ *
10469
+ * This step would be unnecessary if we triggered animateChanges() in useEffect,
10470
+ * but due to potential hydration errors we currently fire them in useLayoutEffect.
10471
+ *
10472
+ * By the time we're safely ready to cancel the optimised WAAPI animation,
10473
+ * the main thread might have been blocked and desynced the two animations.
10474
+ *
10475
+ * Here, we resync the two animations before the optimised WAAPI animation is cancelled.
10476
+ */
10477
+ sync.update(() => {
10478
+ if (value.animation) {
10479
+ value.animation.currentTime = performance.now() - sampledTime;
10480
+ }
10481
+ });
10482
+ /**
10483
+ * We allow the animation to persist until the next frame:
10484
+ * 1. So it continues to play until Framer Motion is ready to render
10485
+ * (avoiding a potential flash of the element's original state)
10486
+ * 2. As all independent transforms share a single transform animation, stopping
10487
+ * it synchronously would prevent subsequent transforms from handing off.
10488
+ */
10489
+ sync.render(cancelOptimisedAnimation);
10490
+ console.log("handing off from", animation.currentTime);
10491
+ return animation.currentTime || 0;
10492
+ }
10493
+ else {
10494
+ cancelOptimisedAnimation();
10495
+ return 0;
10496
+ }
10497
+ }
10498
+
10491
10499
  function startOptimizedAppearAnimation(element, name, keyframes, options, onReady) {
10492
- window.MotionAppearAnimations || (window.MotionAppearAnimations = new Map());
10493
10500
  const id = element.dataset[optimizedAppearDataId];
10494
10501
  if (!id)
10495
10502
  return;
10503
+ window.HandoffAppearAnimations = handoffOptimizedAppearAnimation;
10496
10504
  const storeId = appearStoreId(id, name);
10497
10505
  /**
10498
10506
  * Use a dummy animation to detect when Chrome is ready to start
@@ -10500,15 +10508,20 @@
10500
10508
  * until then.
10501
10509
  */
10502
10510
  const readyAnimation = animateStyle(element, name, [keyframes[0], keyframes[0]], { duration: 1 });
10503
- window.MotionAppearAnimations.set(storeId, {
10511
+ appearAnimationStore.set(storeId, {
10504
10512
  animation: readyAnimation,
10505
10513
  ready: false,
10506
10514
  });
10507
10515
  const startAnimation = () => {
10508
- const animation = animateStyle(element, name, keyframes, options);
10509
- window.MotionAppearAnimations.set(storeId, { animation, ready: true });
10516
+ var _a;
10517
+ const appearAnimation = animateStyle(element, name, keyframes, options);
10518
+ const current = (_a = document.timeline) === null || _a === void 0 ? void 0 : _a.currentTime;
10519
+ if (current) {
10520
+ appearAnimation.startTime = current;
10521
+ }
10522
+ appearAnimationStore.set(storeId, { animation: appearAnimation, ready: true });
10510
10523
  if (onReady)
10511
- onReady(animation);
10524
+ onReady(appearAnimation);
10512
10525
  };
10513
10526
  if (readyAnimation.ready) {
10514
10527
  readyAnimation.ready.then(() => {