framer-motion 8.5.2 → 8.5.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
@@ -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";
2108
+ this.version = "8.5.3";
2109
2109
  /**
2110
2110
  * Duration, in milliseconds, since last updating frame.
2111
2111
  *
@@ -5953,7 +5953,7 @@ function updateMotionValuesFromProps(element, next, prev) {
5953
5953
  * and warn against mismatches.
5954
5954
  */
5955
5955
  if (process.env.NODE_ENV === "development") {
5956
- warnOnce(nextValue.version === "8.5.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.5.2 may not work as expected.`);
5956
+ warnOnce(nextValue.version === "8.5.3", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.5.3 may not work as expected.`);
5957
5957
  }
5958
5958
  }
5959
5959
  else if (isMotionValue(prevValue)) {
@@ -9829,9 +9829,10 @@ function handoffOptimizedAppearAnimation(id, name, value,
9829
9829
  */
9830
9830
  sync) {
9831
9831
  const storeId = appearStoreId(id, transformProps.has(name) ? "transform" : name);
9832
- const { animation, ready } = appearAnimationStore.get(storeId) || {};
9833
- if (!animation)
9832
+ const appearAnimation = appearAnimationStore.get(storeId);
9833
+ if (!appearAnimation)
9834
9834
  return 0;
9835
+ const { animation, startTime } = appearAnimation;
9835
9836
  const cancelOptimisedAnimation = () => {
9836
9837
  appearAnimationStore.delete(storeId);
9837
9838
  /**
@@ -9842,7 +9843,7 @@ sync) {
9842
9843
  }
9843
9844
  catch (e) { }
9844
9845
  };
9845
- if (ready) {
9846
+ if (startTime !== null) {
9846
9847
  const sampledTime = performance.now();
9847
9848
  /**
9848
9849
  * Resync handoff animation with optimised animation.
@@ -9868,7 +9869,13 @@ sync) {
9868
9869
  * it synchronously would prevent subsequent transforms from handing off.
9869
9870
  */
9870
9871
  sync.render(cancelOptimisedAnimation);
9871
- return animation.currentTime || 0;
9872
+ /**
9873
+ * We use main thread timings vs those returned by Animation.currentTime as it
9874
+ * can be the case, particularly in Firefox, that currentTime doesn't return
9875
+ * an updated value for several frames, even as the animation plays smoothly via
9876
+ * the GPU.
9877
+ */
9878
+ return sampledTime - startTime || 0;
9872
9879
  }
9873
9880
  else {
9874
9881
  cancelOptimisedAnimation();
@@ -9897,7 +9904,7 @@ function startOptimizedAppearAnimation(element, name, keyframes, options, onRead
9897
9904
  { duration: 10000, ease: "linear" });
9898
9905
  appearAnimationStore.set(storeId, {
9899
9906
  animation: readyAnimation,
9900
- ready: false,
9907
+ startTime: null,
9901
9908
  });
9902
9909
  const startAnimation = () => {
9903
9910
  readyAnimation.cancel();
@@ -9907,13 +9914,13 @@ function startOptimizedAppearAnimation(element, name, keyframes, options, onRead
9907
9914
  }
9908
9915
  appearAnimationStore.set(storeId, {
9909
9916
  animation: appearAnimation,
9910
- ready: true,
9917
+ startTime: performance.now(),
9911
9918
  });
9912
9919
  if (onReady)
9913
9920
  onReady(appearAnimation);
9914
9921
  };
9915
9922
  if (readyAnimation.ready) {
9916
- readyAnimation.ready.then(startAnimation);
9923
+ readyAnimation.ready.then(startAnimation).catch(noop);
9917
9924
  }
9918
9925
  else {
9919
9926
  startAnimation();
@@ -12,9 +12,10 @@ function handoffOptimizedAppearAnimation(id, name, value,
12
12
  */
13
13
  sync) {
14
14
  const storeId = appearStoreId(id, transformProps.has(name) ? "transform" : name);
15
- const { animation, ready } = appearAnimationStore.get(storeId) || {};
16
- if (!animation)
15
+ const appearAnimation = appearAnimationStore.get(storeId);
16
+ if (!appearAnimation)
17
17
  return 0;
18
+ const { animation, startTime } = appearAnimation;
18
19
  const cancelOptimisedAnimation = () => {
19
20
  appearAnimationStore.delete(storeId);
20
21
  /**
@@ -25,7 +26,7 @@ sync) {
25
26
  }
26
27
  catch (e) { }
27
28
  };
28
- if (ready) {
29
+ if (startTime !== null) {
29
30
  const sampledTime = performance.now();
30
31
  /**
31
32
  * Resync handoff animation with optimised animation.
@@ -51,7 +52,13 @@ sync) {
51
52
  * it synchronously would prevent subsequent transforms from handing off.
52
53
  */
53
54
  sync.render(cancelOptimisedAnimation);
54
- return animation.currentTime || 0;
55
+ /**
56
+ * We use main thread timings vs those returned by Animation.currentTime as it
57
+ * can be the case, particularly in Firefox, that currentTime doesn't return
58
+ * an updated value for several frames, even as the animation plays smoothly via
59
+ * the GPU.
60
+ */
61
+ return sampledTime - startTime || 0;
55
62
  }
56
63
  else {
57
64
  cancelOptimisedAnimation();
@@ -3,6 +3,7 @@ import { animateStyle } from '../waapi/index.mjs';
3
3
  import { optimizedAppearDataId } from './data-id.mjs';
4
4
  import { handoffOptimizedAppearAnimation } from './handoff.mjs';
5
5
  import { appearAnimationStore } from './store.mjs';
6
+ import { noop } from '../../utils/noop.mjs';
6
7
 
7
8
  function startOptimizedAppearAnimation(element, name, keyframes, options, onReady) {
8
9
  const id = element.dataset[optimizedAppearDataId];
@@ -25,7 +26,7 @@ function startOptimizedAppearAnimation(element, name, keyframes, options, onRead
25
26
  { duration: 10000, ease: "linear" });
26
27
  appearAnimationStore.set(storeId, {
27
28
  animation: readyAnimation,
28
- ready: false,
29
+ startTime: null,
29
30
  });
30
31
  const startAnimation = () => {
31
32
  readyAnimation.cancel();
@@ -35,13 +36,13 @@ function startOptimizedAppearAnimation(element, name, keyframes, options, onRead
35
36
  }
36
37
  appearAnimationStore.set(storeId, {
37
38
  animation: appearAnimation,
38
- ready: true,
39
+ startTime: performance.now(),
39
40
  });
40
41
  if (onReady)
41
42
  onReady(appearAnimation);
42
43
  };
43
44
  if (readyAnimation.ready) {
44
- readyAnimation.ready.then(startAnimation);
45
+ readyAnimation.ready.then(startAnimation).catch(noop);
45
46
  }
46
47
  else {
47
48
  startAnimation();
@@ -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", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.5.2 may not work as expected.`);
25
+ warnOnce(nextValue.version === "8.5.3", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.5.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";
28
+ this.version = "8.5.3";
29
29
  /**
30
30
  * Duration, in milliseconds, since last updating frame.
31
31
  *
@@ -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";
2106
+ this.version = "8.5.3";
2107
2107
  /**
2108
2108
  * Duration, in milliseconds, since last updating frame.
2109
2109
  *
@@ -5966,7 +5966,7 @@
5966
5966
  * and warn against mismatches.
5967
5967
  */
5968
5968
  {
5969
- warnOnce(nextValue.version === "8.5.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.5.2 may not work as expected.`);
5969
+ warnOnce(nextValue.version === "8.5.3", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.5.3 may not work as expected.`);
5970
5970
  }
5971
5971
  }
5972
5972
  else if (isMotionValue(prevValue)) {
@@ -10448,9 +10448,10 @@
10448
10448
  */
10449
10449
  sync) {
10450
10450
  const storeId = appearStoreId(id, transformProps.has(name) ? "transform" : name);
10451
- const { animation, ready } = appearAnimationStore.get(storeId) || {};
10452
- if (!animation)
10451
+ const appearAnimation = appearAnimationStore.get(storeId);
10452
+ if (!appearAnimation)
10453
10453
  return 0;
10454
+ const { animation, startTime } = appearAnimation;
10454
10455
  const cancelOptimisedAnimation = () => {
10455
10456
  appearAnimationStore.delete(storeId);
10456
10457
  /**
@@ -10461,7 +10462,7 @@
10461
10462
  }
10462
10463
  catch (e) { }
10463
10464
  };
10464
- if (ready) {
10465
+ if (startTime !== null) {
10465
10466
  const sampledTime = performance.now();
10466
10467
  /**
10467
10468
  * Resync handoff animation with optimised animation.
@@ -10487,7 +10488,13 @@
10487
10488
  * it synchronously would prevent subsequent transforms from handing off.
10488
10489
  */
10489
10490
  sync.render(cancelOptimisedAnimation);
10490
- return animation.currentTime || 0;
10491
+ /**
10492
+ * We use main thread timings vs those returned by Animation.currentTime as it
10493
+ * can be the case, particularly in Firefox, that currentTime doesn't return
10494
+ * an updated value for several frames, even as the animation plays smoothly via
10495
+ * the GPU.
10496
+ */
10497
+ return sampledTime - startTime || 0;
10491
10498
  }
10492
10499
  else {
10493
10500
  cancelOptimisedAnimation();
@@ -10516,7 +10523,7 @@
10516
10523
  { duration: 10000, ease: "linear" });
10517
10524
  appearAnimationStore.set(storeId, {
10518
10525
  animation: readyAnimation,
10519
- ready: false,
10526
+ startTime: null,
10520
10527
  });
10521
10528
  const startAnimation = () => {
10522
10529
  readyAnimation.cancel();
@@ -10526,13 +10533,13 @@
10526
10533
  }
10527
10534
  appearAnimationStore.set(storeId, {
10528
10535
  animation: appearAnimation,
10529
- ready: true,
10536
+ startTime: performance.now(),
10530
10537
  });
10531
10538
  if (onReady)
10532
10539
  onReady(appearAnimation);
10533
10540
  };
10534
10541
  if (readyAnimation.ready) {
10535
- readyAnimation.ready.then(startAnimation);
10542
+ readyAnimation.ready.then(startAnimation).catch(noop);
10536
10543
  }
10537
10544
  else {
10538
10545
  startAnimation();