framer-motion 8.2.0 → 8.2.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.
package/dist/cjs/index.js CHANGED
@@ -2055,7 +2055,7 @@ class MotionValue {
2055
2055
  * This will be replaced by the build step with the latest version number.
2056
2056
  * When MotionValues are provided to motion components, warn if versions are mixed.
2057
2057
  */
2058
- this.version = "8.2.0";
2058
+ this.version = "8.2.2";
2059
2059
  /**
2060
2060
  * Duration, in milliseconds, since last updating frame.
2061
2061
  *
@@ -5911,7 +5911,7 @@ function updateMotionValuesFromProps(element, next, prev) {
5911
5911
  * and warn against mismatches.
5912
5912
  */
5913
5913
  if (process.env.NODE_ENV === "development") {
5914
- warnOnce(nextValue.version === "8.2.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.2.0 may not work as expected.`);
5914
+ warnOnce(nextValue.version === "8.2.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.2.2 may not work as expected.`);
5915
5915
  }
5916
5916
  }
5917
5917
  else if (isMotionValue(prevValue)) {
@@ -9439,11 +9439,6 @@ function animationControls() {
9439
9439
  * Track whether the host component has mounted.
9440
9440
  */
9441
9441
  let hasMounted = false;
9442
- /**
9443
- * Pending animations that are started before a component is mounted.
9444
- * TODO: Remove this as animations should only run in effects
9445
- */
9446
- const pendingAnimations = [];
9447
9442
  /**
9448
9443
  * A collection of linked component animation controls.
9449
9444
  */
@@ -9454,29 +9449,14 @@ function animationControls() {
9454
9449
  return () => void subscribers.delete(visualElement);
9455
9450
  },
9456
9451
  start(definition, transitionOverride) {
9457
- /**
9458
- * TODO: We only perform this hasMounted check because in Framer we used to
9459
- * encourage the ability to start an animation within the render phase. This
9460
- * isn't behaviour concurrent-safe so when we make Framer concurrent-safe
9461
- * we can ditch this.
9462
- */
9463
- if (hasMounted) {
9464
- const animations = [];
9465
- subscribers.forEach((visualElement) => {
9466
- animations.push(animateVisualElement(visualElement, definition, {
9467
- transitionOverride,
9468
- }));
9469
- });
9470
- return Promise.all(animations);
9471
- }
9472
- else {
9473
- return new Promise((resolve) => {
9474
- pendingAnimations.push({
9475
- animation: [definition, transitionOverride],
9476
- resolve,
9477
- });
9478
- });
9479
- }
9452
+ heyListen.invariant(hasMounted, "controls.start() should only be called after a component has mounted. Consider calling within a useEffect hook.");
9453
+ const animations = [];
9454
+ subscribers.forEach((visualElement) => {
9455
+ animations.push(animateVisualElement(visualElement, definition, {
9456
+ transitionOverride,
9457
+ }));
9458
+ });
9459
+ return Promise.all(animations);
9480
9460
  },
9481
9461
  set(definition) {
9482
9462
  heyListen.invariant(hasMounted, "controls.set() should only be called after a component has mounted. Consider calling within a useEffect hook.");
@@ -9491,9 +9471,6 @@ function animationControls() {
9491
9471
  },
9492
9472
  mount() {
9493
9473
  hasMounted = true;
9494
- pendingAnimations.forEach(({ animation, resolve }) => {
9495
- controls.start(...animation).then(resolve);
9496
- });
9497
9474
  return () => {
9498
9475
  hasMounted = false;
9499
9476
  controls.stop();
@@ -9534,7 +9511,7 @@ function animationControls() {
9534
9511
  */
9535
9512
  function useAnimationControls() {
9536
9513
  const controls = useConstant(animationControls);
9537
- React.useEffect(controls.mount, []);
9514
+ useIsomorphicLayoutEffect(controls.mount, []);
9538
9515
  return controls;
9539
9516
  }
9540
9517
  const useAnimation = useAnimationControls;
@@ -1,5 +1,5 @@
1
1
  import { invariant } from 'hey-listen';
2
- import { stopAnimation, animateVisualElement } from '../../render/utils/animation.mjs';
2
+ import { animateVisualElement, stopAnimation } from '../../render/utils/animation.mjs';
3
3
  import { setValues } from '../../render/utils/setters.mjs';
4
4
 
5
5
  /**
@@ -10,11 +10,6 @@ function animationControls() {
10
10
  * Track whether the host component has mounted.
11
11
  */
12
12
  let hasMounted = false;
13
- /**
14
- * Pending animations that are started before a component is mounted.
15
- * TODO: Remove this as animations should only run in effects
16
- */
17
- const pendingAnimations = [];
18
13
  /**
19
14
  * A collection of linked component animation controls.
20
15
  */
@@ -25,29 +20,14 @@ function animationControls() {
25
20
  return () => void subscribers.delete(visualElement);
26
21
  },
27
22
  start(definition, transitionOverride) {
28
- /**
29
- * TODO: We only perform this hasMounted check because in Framer we used to
30
- * encourage the ability to start an animation within the render phase. This
31
- * isn't behaviour concurrent-safe so when we make Framer concurrent-safe
32
- * we can ditch this.
33
- */
34
- if (hasMounted) {
35
- const animations = [];
36
- subscribers.forEach((visualElement) => {
37
- animations.push(animateVisualElement(visualElement, definition, {
38
- transitionOverride,
39
- }));
40
- });
41
- return Promise.all(animations);
42
- }
43
- else {
44
- return new Promise((resolve) => {
45
- pendingAnimations.push({
46
- animation: [definition, transitionOverride],
47
- resolve,
48
- });
49
- });
50
- }
23
+ invariant(hasMounted, "controls.start() should only be called after a component has mounted. Consider calling within a useEffect hook.");
24
+ const animations = [];
25
+ subscribers.forEach((visualElement) => {
26
+ animations.push(animateVisualElement(visualElement, definition, {
27
+ transitionOverride,
28
+ }));
29
+ });
30
+ return Promise.all(animations);
51
31
  },
52
32
  set(definition) {
53
33
  invariant(hasMounted, "controls.set() should only be called after a component has mounted. Consider calling within a useEffect hook.");
@@ -62,9 +42,6 @@ function animationControls() {
62
42
  },
63
43
  mount() {
64
44
  hasMounted = true;
65
- pendingAnimations.forEach(({ animation, resolve }) => {
66
- controls.start(...animation).then(resolve);
67
- });
68
45
  return () => {
69
46
  hasMounted = false;
70
47
  controls.stop();
@@ -1,6 +1,6 @@
1
1
  import { animationControls } from './animation-controls.mjs';
2
- import { useEffect } from 'react';
3
2
  import { useConstant } from '../../utils/use-constant.mjs';
3
+ import { useIsomorphicLayoutEffect } from '../../utils/use-isomorphic-effect.mjs';
4
4
 
5
5
  /**
6
6
  * Creates `AnimationControls`, which can be used to manually start, stop
@@ -33,7 +33,7 @@ import { useConstant } from '../../utils/use-constant.mjs';
33
33
  */
34
34
  function useAnimationControls() {
35
35
  const controls = useConstant(animationControls);
36
- useEffect(controls.mount, []);
36
+ useIsomorphicLayoutEffect(controls.mount, []);
37
37
  return controls;
38
38
  }
39
39
  const useAnimation = useAnimationControls;
@@ -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.2.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.2.0 may not work as expected.`);
25
+ warnOnce(nextValue.version === "8.2.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.2.2 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.2.0";
28
+ this.version = "8.2.2";
29
29
  /**
30
30
  * Duration, in milliseconds, since last updating frame.
31
31
  *
@@ -2053,7 +2053,7 @@
2053
2053
  * This will be replaced by the build step with the latest version number.
2054
2054
  * When MotionValues are provided to motion components, warn if versions are mixed.
2055
2055
  */
2056
- this.version = "8.2.0";
2056
+ this.version = "8.2.2";
2057
2057
  /**
2058
2058
  * Duration, in milliseconds, since last updating frame.
2059
2059
  *
@@ -5924,7 +5924,7 @@
5924
5924
  * and warn against mismatches.
5925
5925
  */
5926
5926
  {
5927
- warnOnce(nextValue.version === "8.2.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.2.0 may not work as expected.`);
5927
+ warnOnce(nextValue.version === "8.2.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.2.2 may not work as expected.`);
5928
5928
  }
5929
5929
  }
5930
5930
  else if (isMotionValue(prevValue)) {
@@ -10058,11 +10058,6 @@
10058
10058
  * Track whether the host component has mounted.
10059
10059
  */
10060
10060
  let hasMounted = false;
10061
- /**
10062
- * Pending animations that are started before a component is mounted.
10063
- * TODO: Remove this as animations should only run in effects
10064
- */
10065
- const pendingAnimations = [];
10066
10061
  /**
10067
10062
  * A collection of linked component animation controls.
10068
10063
  */
@@ -10073,29 +10068,14 @@
10073
10068
  return () => void subscribers.delete(visualElement);
10074
10069
  },
10075
10070
  start(definition, transitionOverride) {
10076
- /**
10077
- * TODO: We only perform this hasMounted check because in Framer we used to
10078
- * encourage the ability to start an animation within the render phase. This
10079
- * isn't behaviour concurrent-safe so when we make Framer concurrent-safe
10080
- * we can ditch this.
10081
- */
10082
- if (hasMounted) {
10083
- const animations = [];
10084
- subscribers.forEach((visualElement) => {
10085
- animations.push(animateVisualElement(visualElement, definition, {
10086
- transitionOverride,
10087
- }));
10088
- });
10089
- return Promise.all(animations);
10090
- }
10091
- else {
10092
- return new Promise((resolve) => {
10093
- pendingAnimations.push({
10094
- animation: [definition, transitionOverride],
10095
- resolve,
10096
- });
10097
- });
10098
- }
10071
+ invariant(hasMounted, "controls.start() should only be called after a component has mounted. Consider calling within a useEffect hook.");
10072
+ const animations = [];
10073
+ subscribers.forEach((visualElement) => {
10074
+ animations.push(animateVisualElement(visualElement, definition, {
10075
+ transitionOverride,
10076
+ }));
10077
+ });
10078
+ return Promise.all(animations);
10099
10079
  },
10100
10080
  set(definition) {
10101
10081
  invariant(hasMounted, "controls.set() should only be called after a component has mounted. Consider calling within a useEffect hook.");
@@ -10110,9 +10090,6 @@
10110
10090
  },
10111
10091
  mount() {
10112
10092
  hasMounted = true;
10113
- pendingAnimations.forEach(({ animation, resolve }) => {
10114
- controls.start(...animation).then(resolve);
10115
- });
10116
10093
  return () => {
10117
10094
  hasMounted = false;
10118
10095
  controls.stop();
@@ -10153,7 +10130,7 @@
10153
10130
  */
10154
10131
  function useAnimationControls() {
10155
10132
  const controls = useConstant(animationControls);
10156
- React.useEffect(controls.mount, []);
10133
+ useIsomorphicLayoutEffect(controls.mount, []);
10157
10134
  return controls;
10158
10135
  }
10159
10136
  const useAnimation = useAnimationControls;