framer-motion 7.0.3 → 7.1.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 (186) hide show
  1. package/dist/cjs/index.js +2090 -2304
  2. package/dist/es/animation/animate.mjs +4 -5
  3. package/dist/es/animation/animation-controls.mjs +22 -24
  4. package/dist/es/animation/use-animated-state.mjs +23 -25
  5. package/dist/es/animation/use-animation.mjs +2 -2
  6. package/dist/es/animation/utils/default-transitions.mjs +13 -14
  7. package/dist/es/animation/utils/easing.mjs +20 -21
  8. package/dist/es/animation/utils/is-animatable.mjs +1 -1
  9. package/dist/es/animation/utils/is-keyframes-target.mjs +1 -1
  10. package/dist/es/animation/utils/transitions.mjs +30 -31
  11. package/dist/es/components/AnimatePresence/PresenceChild.mjs +18 -31
  12. package/dist/es/components/AnimatePresence/index.mjs +33 -35
  13. package/dist/es/components/AnimatePresence/use-presence.mjs +5 -5
  14. package/dist/es/components/AnimateSharedLayout.mjs +4 -5
  15. package/dist/es/components/LayoutGroup/index.mjs +12 -16
  16. package/dist/es/components/LazyMotion/index.mjs +9 -10
  17. package/dist/es/components/MotionConfig/index.mjs +5 -5
  18. package/dist/es/components/Reorder/Group.mjs +16 -16
  19. package/dist/es/components/Reorder/Item.mjs +14 -18
  20. package/dist/es/components/Reorder/index.mjs +3 -3
  21. package/dist/es/components/Reorder/utils/check-reorder.mjs +6 -6
  22. package/dist/es/context/DeprecatedLayoutGroupContext.mjs +1 -1
  23. package/dist/es/context/LayoutGroupContext.mjs +1 -1
  24. package/dist/es/context/LazyContext.mjs +1 -1
  25. package/dist/es/context/MotionConfigContext.mjs +2 -2
  26. package/dist/es/context/MotionContext/create.mjs +2 -2
  27. package/dist/es/context/MotionContext/index.mjs +1 -1
  28. package/dist/es/context/MotionContext/utils.mjs +1 -1
  29. package/dist/es/context/PresenceContext.mjs +1 -1
  30. package/dist/es/context/ReorderContext.mjs +1 -1
  31. package/dist/es/context/SwitchLayoutGroupContext.mjs +1 -1
  32. package/dist/es/events/event-info.mjs +11 -17
  33. package/dist/es/events/use-dom-event.mjs +4 -5
  34. package/dist/es/events/use-pointer-event.mjs +2 -2
  35. package/dist/es/events/utils.mjs +3 -9
  36. package/dist/es/gestures/PanSession.mjs +42 -47
  37. package/dist/es/gestures/drag/VisualElementDragControls.mjs +147 -157
  38. package/dist/es/gestures/drag/use-drag-controls.mjs +10 -12
  39. package/dist/es/gestures/drag/use-drag.mjs +4 -4
  40. package/dist/es/gestures/drag/utils/constraints.mjs +12 -17
  41. package/dist/es/gestures/drag/utils/lock.mjs +17 -17
  42. package/dist/es/gestures/use-focus-gesture.mjs +3 -4
  43. package/dist/es/gestures/use-hover-gesture.mjs +2 -3
  44. package/dist/es/gestures/use-pan-gesture.mjs +9 -10
  45. package/dist/es/gestures/use-tap-gesture.mjs +5 -6
  46. package/dist/es/gestures/utils/event-type.mjs +1 -1
  47. package/dist/es/gestures/utils/is-node-or-child.mjs +1 -1
  48. package/dist/es/index.mjs +1 -0
  49. package/dist/es/motion/features/animations.mjs +9 -11
  50. package/dist/es/motion/features/definitions.mjs +5 -5
  51. package/dist/es/motion/features/drag.mjs +1 -1
  52. package/dist/es/motion/features/gestures.mjs +1 -1
  53. package/dist/es/motion/features/layout/MeasureLayout.mjs +32 -40
  54. package/dist/es/motion/features/layout/index.mjs +1 -1
  55. package/dist/es/motion/features/use-features.mjs +8 -9
  56. package/dist/es/motion/features/use-projection.mjs +10 -11
  57. package/dist/es/motion/features/viewport/observers.mjs +12 -12
  58. package/dist/es/motion/features/viewport/use-viewport.mjs +17 -20
  59. package/dist/es/motion/index.mjs +13 -16
  60. package/dist/es/motion/utils/VisualElementHandler.mjs +10 -16
  61. package/dist/es/motion/utils/is-forced-motion-value.mjs +1 -2
  62. package/dist/es/motion/utils/make-renderless-component.mjs +2 -2
  63. package/dist/es/motion/utils/use-motion-ref.mjs +1 -1
  64. package/dist/es/motion/utils/use-visual-element.mjs +13 -13
  65. package/dist/es/motion/utils/use-visual-state.mjs +26 -31
  66. package/dist/es/motion/utils/valid-prop.mjs +1 -1
  67. package/dist/es/projection/animation/mix-values.mjs +12 -16
  68. package/dist/es/projection/geometry/conversion.mjs +4 -6
  69. package/dist/es/projection/geometry/delta-apply.mjs +14 -20
  70. package/dist/es/projection/geometry/delta-calc.mjs +2 -5
  71. package/dist/es/projection/geometry/delta-remove.mjs +6 -13
  72. package/dist/es/projection/geometry/models.mjs +7 -7
  73. package/dist/es/projection/node/DocumentProjectionNode.mjs +5 -5
  74. package/dist/es/projection/node/HTMLProjectionNode.mjs +8 -10
  75. package/dist/es/projection/node/create-projection-node.mjs +283 -307
  76. package/dist/es/projection/node/group.mjs +6 -8
  77. package/dist/es/projection/node/id.mjs +2 -2
  78. package/dist/es/projection/node/state.mjs +1 -1
  79. package/dist/es/projection/shared/stack.mjs +26 -27
  80. package/dist/es/projection/styles/scale-border-radius.mjs +5 -5
  81. package/dist/es/projection/styles/scale-box-shadow.mjs +18 -19
  82. package/dist/es/projection/styles/scale-correction.mjs +1 -1
  83. package/dist/es/projection/styles/transform.mjs +12 -12
  84. package/dist/es/projection/use-reset-projection.mjs +2 -2
  85. package/dist/es/projection/utils/has-transform.mjs +1 -2
  86. package/dist/es/projection/utils/measure.mjs +2 -2
  87. package/dist/es/render/dom/create-visual-element.mjs +1 -1
  88. package/dist/es/render/dom/features-animation.mjs +1 -2
  89. package/dist/es/render/dom/features-max.mjs +1 -2
  90. package/dist/es/render/dom/motion-minimal.mjs +1 -1
  91. package/dist/es/render/dom/motion-proxy.mjs +3 -4
  92. package/dist/es/render/dom/motion.mjs +2 -5
  93. package/dist/es/render/dom/use-render.mjs +6 -9
  94. package/dist/es/render/dom/utils/camel-to-dash.mjs +3 -5
  95. package/dist/es/render/dom/utils/create-config.mjs +5 -5
  96. package/dist/es/render/dom/utils/css-variables-conversion.mjs +19 -20
  97. package/dist/es/render/dom/utils/filter-props.mjs +4 -6
  98. package/dist/es/render/dom/utils/parse-dom-variant.mjs +2 -2
  99. package/dist/es/render/dom/utils/unit-conversion.mjs +68 -99
  100. package/dist/es/render/dom/value-types/animatable-none.mjs +1 -1
  101. package/dist/es/render/dom/value-types/defaults.mjs +4 -5
  102. package/dist/es/render/dom/value-types/dimensions.mjs +2 -4
  103. package/dist/es/render/dom/value-types/find.mjs +2 -3
  104. package/dist/es/render/dom/value-types/get-as-type.mjs +1 -1
  105. package/dist/es/render/dom/value-types/number.mjs +2 -2
  106. package/dist/es/render/dom/value-types/test.mjs +1 -1
  107. package/dist/es/render/dom/value-types/type-auto.mjs +3 -3
  108. package/dist/es/render/dom/value-types/type-int.mjs +1 -2
  109. package/dist/es/render/html/config-motion.mjs +1 -1
  110. package/dist/es/render/html/use-props.mjs +11 -13
  111. package/dist/es/render/html/utils/build-styles.mjs +8 -8
  112. package/dist/es/render/html/utils/build-transform.mjs +11 -16
  113. package/dist/es/render/html/utils/create-render-state.mjs +2 -2
  114. package/dist/es/render/html/utils/render.mjs +2 -3
  115. package/dist/es/render/html/utils/scrape-motion-values.mjs +3 -3
  116. package/dist/es/render/html/utils/transform.mjs +6 -10
  117. package/dist/es/render/html/visual-element.mjs +22 -23
  118. package/dist/es/render/index.mjs +359 -364
  119. package/dist/es/render/svg/config-motion.mjs +2 -3
  120. package/dist/es/render/svg/lowercase-elements.mjs +1 -1
  121. package/dist/es/render/svg/use-props.mjs +5 -6
  122. package/dist/es/render/svg/utils/build-attrs.mjs +2 -2
  123. package/dist/es/render/svg/utils/camel-case-attrs.mjs +1 -1
  124. package/dist/es/render/svg/utils/create-render-state.mjs +1 -2
  125. package/dist/es/render/svg/utils/path.mjs +7 -10
  126. package/dist/es/render/svg/utils/render.mjs +1 -1
  127. package/dist/es/render/svg/utils/scrape-motion-values.mjs +3 -3
  128. package/dist/es/render/svg/utils/transform-origin.mjs +3 -3
  129. package/dist/es/render/svg/visual-element.mjs +6 -4
  130. package/dist/es/render/utils/animation-state.mjs +71 -87
  131. package/dist/es/render/utils/animation.mjs +48 -60
  132. package/dist/es/render/utils/compare-by-depth.mjs +1 -3
  133. package/dist/es/render/utils/flat-tree.mjs +9 -10
  134. package/dist/es/render/utils/lifecycles.mjs +12 -19
  135. package/dist/es/render/utils/motion-values.mjs +16 -8
  136. package/dist/es/render/utils/setters.mjs +19 -19
  137. package/dist/es/render/utils/variants.mjs +6 -8
  138. package/dist/es/utils/array.mjs +9 -10
  139. package/dist/es/utils/is-browser.mjs +1 -1
  140. package/dist/es/utils/is-numerical-string.mjs +1 -1
  141. package/dist/es/utils/is-zero-value-string.mjs +1 -1
  142. package/dist/es/utils/process.mjs +2 -2
  143. package/dist/es/utils/resolve-value.mjs +2 -2
  144. package/dist/es/utils/shallow-compare.mjs +2 -2
  145. package/dist/es/utils/subscription-manager.mjs +15 -17
  146. package/dist/es/utils/time-conversion.mjs +1 -1
  147. package/dist/es/utils/transform.mjs +10 -15
  148. package/dist/es/utils/use-animation-frame.mjs +5 -6
  149. package/dist/es/utils/use-constant.mjs +1 -1
  150. package/dist/es/utils/use-cycle.mjs +9 -10
  151. package/dist/es/utils/use-force-update.mjs +4 -5
  152. package/dist/es/utils/use-in-view.mjs +7 -9
  153. package/dist/es/utils/use-instant-transition-state.mjs +1 -1
  154. package/dist/es/utils/use-instant-transition.mjs +6 -9
  155. package/dist/es/utils/use-is-mounted.mjs +3 -3
  156. package/dist/es/utils/use-isomorphic-effect.mjs +1 -1
  157. package/dist/es/utils/use-reduced-motion.mjs +8 -11
  158. package/dist/es/utils/use-unmount-effect.mjs +1 -1
  159. package/dist/es/utils/warn-once.mjs +1 -1
  160. package/dist/es/value/index.mjs +53 -59
  161. package/dist/es/value/use-combine-values.mjs +3 -3
  162. package/dist/es/value/use-inverted-scale.mjs +9 -11
  163. package/dist/es/value/use-motion-template.mjs +5 -9
  164. package/dist/es/value/use-motion-value.mjs +4 -5
  165. package/dist/es/value/use-on-change.mjs +4 -4
  166. package/dist/es/value/use-scroll.mjs +9 -11
  167. package/dist/es/value/use-spring.mjs +8 -10
  168. package/dist/es/value/use-time.mjs +2 -2
  169. package/dist/es/value/use-transform.mjs +6 -10
  170. package/dist/es/value/use-velocity.mjs +3 -3
  171. package/dist/es/value/use-will-change/index.mjs +50 -0
  172. package/dist/es/value/use-will-change/is.mjs +7 -0
  173. package/dist/es/value/utils/is-motion-value.mjs +1 -1
  174. package/dist/es/value/utils/resolve-motion-value.mjs +1 -1
  175. package/dist/framer-motion.dev.js +2134 -2414
  176. package/dist/framer-motion.js +1 -1
  177. package/dist/index.d.ts +9 -2
  178. package/dist/projection.dev.js +1154 -1300
  179. package/dist/size-rollup-dom-animation.js +1 -1
  180. package/dist/size-rollup-dom-max.js +1 -1
  181. package/dist/size-rollup-m.js +1 -1
  182. package/dist/size-webpack-dom-animation.js +1 -1
  183. package/dist/size-webpack-dom-max.js +1 -1
  184. package/dist/size-webpack-m.js +1 -1
  185. package/dist/three-entry.d.ts +0 -1
  186. package/package.json +12 -12
@@ -1,37 +1,32 @@
1
- import { __read, __rest, __assign } from 'tslib';
1
+ import { __rest } from 'tslib';
2
2
  import { startAnimation } from '../../animation/utils/transitions.mjs';
3
3
  import { setTarget } from './setters.mjs';
4
4
  import { resolveVariant } from './variants.mjs';
5
5
  import { isTransformProp } from '../html/utils/transform.mjs';
6
+ import { isWillChangeMotionValue } from '../../value/use-will-change/is.mjs';
6
7
 
7
- function animateVisualElement(visualElement, definition, options) {
8
- if (options === void 0) { options = {}; }
8
+ function animateVisualElement(visualElement, definition, options = {}) {
9
9
  visualElement.notifyAnimationStart(definition);
10
- var animation;
10
+ let animation;
11
11
  if (Array.isArray(definition)) {
12
- var animations = definition.map(function (variant) {
13
- return animateVariant(visualElement, variant, options);
14
- });
12
+ const animations = definition.map((variant) => animateVariant(visualElement, variant, options));
15
13
  animation = Promise.all(animations);
16
14
  }
17
15
  else if (typeof definition === "string") {
18
16
  animation = animateVariant(visualElement, definition, options);
19
17
  }
20
18
  else {
21
- var resolvedDefinition = typeof definition === "function"
19
+ const resolvedDefinition = typeof definition === "function"
22
20
  ? resolveVariant(visualElement, definition, options.custom)
23
21
  : definition;
24
22
  animation = animateTarget(visualElement, resolvedDefinition, options);
25
23
  }
26
- return animation.then(function () {
27
- return visualElement.notifyAnimationComplete(definition);
28
- });
24
+ return animation.then(() => visualElement.notifyAnimationComplete(definition));
29
25
  }
30
- function animateVariant(visualElement, variant, options) {
26
+ function animateVariant(visualElement, variant, options = {}) {
31
27
  var _a;
32
- if (options === void 0) { options = {}; }
33
- var resolved = resolveVariant(visualElement, variant, options.custom);
34
- var _b = (resolved || {}).transition, transition = _b === void 0 ? visualElement.getDefaultTransition() || {} : _b;
28
+ const resolved = resolveVariant(visualElement, variant, options.custom);
29
+ let { transition = visualElement.getDefaultTransition() || {} } = resolved || {};
35
30
  if (options.transitionOverride) {
36
31
  transition = options.transitionOverride;
37
32
  }
@@ -39,29 +34,28 @@ function animateVariant(visualElement, variant, options) {
39
34
  * If we have a variant, create a callback that runs it as an animation.
40
35
  * Otherwise, we resolve a Promise immediately for a composable no-op.
41
36
  */
42
- var getAnimation = resolved
43
- ? function () { return animateTarget(visualElement, resolved, options); }
44
- : function () { return Promise.resolve(); };
37
+ const getAnimation = resolved
38
+ ? () => animateTarget(visualElement, resolved, options)
39
+ : () => Promise.resolve();
45
40
  /**
46
41
  * If we have children, create a callback that runs all their animations.
47
42
  * Otherwise, we resolve a Promise immediately for a composable no-op.
48
43
  */
49
- var getChildAnimations = ((_a = visualElement.variantChildren) === null || _a === void 0 ? void 0 : _a.size)
50
- ? function (forwardDelay) {
51
- if (forwardDelay === void 0) { forwardDelay = 0; }
52
- var _a = transition.delayChildren, delayChildren = _a === void 0 ? 0 : _a, staggerChildren = transition.staggerChildren, staggerDirection = transition.staggerDirection;
44
+ const getChildAnimations = ((_a = visualElement.variantChildren) === null || _a === void 0 ? void 0 : _a.size)
45
+ ? (forwardDelay = 0) => {
46
+ const { delayChildren = 0, staggerChildren, staggerDirection, } = transition;
53
47
  return animateChildren(visualElement, variant, delayChildren + forwardDelay, staggerChildren, staggerDirection, options);
54
48
  }
55
- : function () { return Promise.resolve(); };
49
+ : () => Promise.resolve();
56
50
  /**
57
51
  * If the transition explicitly defines a "when" option, we need to resolve either
58
52
  * this animation or all children animations before playing the other.
59
53
  */
60
- var when = transition.when;
54
+ const { when } = transition;
61
55
  if (when) {
62
- var _c = __read(when === "beforeChildren"
56
+ const [first, last] = when === "beforeChildren"
63
57
  ? [getAnimation, getChildAnimations]
64
- : [getChildAnimations, getAnimation], 2), first = _c[0], last = _c[1];
58
+ : [getChildAnimations, getAnimation];
65
59
  return first().then(last);
66
60
  }
67
61
  else {
@@ -71,61 +65,56 @@ function animateVariant(visualElement, variant, options) {
71
65
  /**
72
66
  * @internal
73
67
  */
74
- function animateTarget(visualElement, definition, _a) {
75
- var _b;
76
- var _c = _a === void 0 ? {} : _a, _d = _c.delay, delay = _d === void 0 ? 0 : _d, transitionOverride = _c.transitionOverride, type = _c.type;
77
- var _e = visualElement.makeTargetAnimatable(definition), _f = _e.transition, transition = _f === void 0 ? visualElement.getDefaultTransition() : _f, transitionEnd = _e.transitionEnd, target = __rest(_e, ["transition", "transitionEnd"]);
68
+ function animateTarget(visualElement, definition, { delay = 0, transitionOverride, type } = {}) {
69
+ var _a;
70
+ let _b = visualElement.makeTargetAnimatable(definition), { transition = visualElement.getDefaultTransition(), transitionEnd } = _b, target = __rest(_b, ["transition", "transitionEnd"]);
71
+ const willChange = visualElement.getValue("willChange");
78
72
  if (transitionOverride)
79
73
  transition = transitionOverride;
80
- var animations = [];
81
- var animationTypeState = type && ((_b = visualElement.animationState) === null || _b === void 0 ? void 0 : _b.getState()[type]);
82
- for (var key in target) {
83
- var value = visualElement.getValue(key);
84
- var valueTarget = target[key];
74
+ const animations = [];
75
+ const animationTypeState = type && ((_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.getState()[type]);
76
+ for (const key in target) {
77
+ const value = visualElement.getValue(key);
78
+ const valueTarget = target[key];
85
79
  if (!value ||
86
80
  valueTarget === undefined ||
87
81
  (animationTypeState &&
88
82
  shouldBlockAnimation(animationTypeState, key))) {
89
83
  continue;
90
84
  }
91
- var valueTransition = __assign({ delay: delay }, transition);
85
+ let valueTransition = Object.assign({ delay }, transition);
92
86
  /**
93
87
  * Make animation instant if this is a transform prop and we should reduce motion.
94
88
  */
95
89
  if (visualElement.shouldReduceMotion && isTransformProp(key)) {
96
- valueTransition = __assign(__assign({}, valueTransition), { type: false, delay: 0 });
90
+ valueTransition = Object.assign(Object.assign({}, valueTransition), { type: false, delay: 0 });
91
+ }
92
+ let animation = startAnimation(key, value, valueTarget, valueTransition);
93
+ if (isWillChangeMotionValue(willChange)) {
94
+ willChange.add(key);
95
+ animation = animation.then(() => willChange.remove(key));
97
96
  }
98
- var animation = startAnimation(key, value, valueTarget, valueTransition);
99
97
  animations.push(animation);
100
98
  }
101
- return Promise.all(animations).then(function () {
99
+ return Promise.all(animations).then(() => {
102
100
  transitionEnd && setTarget(visualElement, transitionEnd);
103
101
  });
104
102
  }
105
- function animateChildren(visualElement, variant, delayChildren, staggerChildren, staggerDirection, options) {
106
- if (delayChildren === void 0) { delayChildren = 0; }
107
- if (staggerChildren === void 0) { staggerChildren = 0; }
108
- if (staggerDirection === void 0) { staggerDirection = 1; }
109
- var animations = [];
110
- var maxStaggerDuration = (visualElement.variantChildren.size - 1) * staggerChildren;
111
- var generateStaggerDuration = staggerDirection === 1
112
- ? function (i) {
113
- if (i === void 0) { i = 0; }
114
- return i * staggerChildren;
115
- }
116
- : function (i) {
117
- if (i === void 0) { i = 0; }
118
- return maxStaggerDuration - i * staggerChildren;
119
- };
103
+ function animateChildren(visualElement, variant, delayChildren = 0, staggerChildren = 0, staggerDirection = 1, options) {
104
+ const animations = [];
105
+ const maxStaggerDuration = (visualElement.variantChildren.size - 1) * staggerChildren;
106
+ const generateStaggerDuration = staggerDirection === 1
107
+ ? (i = 0) => i * staggerChildren
108
+ : (i = 0) => maxStaggerDuration - i * staggerChildren;
120
109
  Array.from(visualElement.variantChildren)
121
110
  .sort(sortByTreeOrder)
122
- .forEach(function (child, i) {
123
- animations.push(animateVariant(child, variant, __assign(__assign({}, options), { delay: delayChildren + generateStaggerDuration(i) })).then(function () { return child.notifyAnimationComplete(variant); }));
111
+ .forEach((child, i) => {
112
+ animations.push(animateVariant(child, variant, Object.assign(Object.assign({}, options), { delay: delayChildren + generateStaggerDuration(i) })).then(() => child.notifyAnimationComplete(variant)));
124
113
  });
125
114
  return Promise.all(animations);
126
115
  }
127
116
  function stopAnimation(visualElement) {
128
- visualElement.forEachValue(function (value) { return value.stop(); });
117
+ visualElement.forEachValue((value) => value.stop());
129
118
  }
130
119
  function sortByTreeOrder(a, b) {
131
120
  return a.sortNodePosition(b);
@@ -136,9 +125,8 @@ function sortByTreeOrder(a, b) {
136
125
  * posed problems if an animation was triggered by afterChildren and protectedKeys
137
126
  * had been set to true in the meantime.
138
127
  */
139
- function shouldBlockAnimation(_a, key) {
140
- var protectedKeys = _a.protectedKeys, needsAnimating = _a.needsAnimating;
141
- var shouldBlock = protectedKeys.hasOwnProperty(key) && needsAnimating[key] !== true;
128
+ function shouldBlockAnimation({ protectedKeys, needsAnimating }, key) {
129
+ const shouldBlock = protectedKeys.hasOwnProperty(key) && needsAnimating[key] !== true;
142
130
  needsAnimating[key] = false;
143
131
  return shouldBlock;
144
132
  }
@@ -1,5 +1,3 @@
1
- var compareByDepth = function (a, b) {
2
- return a.depth - b.depth;
3
- };
1
+ const compareByDepth = (a, b) => a.depth - b.depth;
4
2
 
5
3
  export { compareByDepth };
@@ -1,25 +1,24 @@
1
1
  import { addUniqueItem, removeItem } from '../../utils/array.mjs';
2
2
  import { compareByDepth } from './compare-by-depth.mjs';
3
3
 
4
- var FlatTree = /** @class */ (function () {
5
- function FlatTree() {
4
+ class FlatTree {
5
+ constructor() {
6
6
  this.children = [];
7
7
  this.isDirty = false;
8
8
  }
9
- FlatTree.prototype.add = function (child) {
9
+ add(child) {
10
10
  addUniqueItem(this.children, child);
11
11
  this.isDirty = true;
12
- };
13
- FlatTree.prototype.remove = function (child) {
12
+ }
13
+ remove(child) {
14
14
  removeItem(this.children, child);
15
15
  this.isDirty = true;
16
- };
17
- FlatTree.prototype.forEach = function (callback) {
16
+ }
17
+ forEach(callback) {
18
18
  this.isDirty && this.children.sort(compareByDepth);
19
19
  this.isDirty = false;
20
20
  this.children.forEach(callback);
21
- };
22
- return FlatTree;
23
- }());
21
+ }
22
+ }
24
23
 
25
24
  export { FlatTree };
@@ -1,7 +1,6 @@
1
- import { __spreadArray, __read } from 'tslib';
2
1
  import { SubscriptionManager } from '../../utils/subscription-manager.mjs';
3
2
 
4
- var names = [
3
+ const names = [
5
4
  "LayoutMeasure",
6
5
  "BeforeLayoutMeasure",
7
6
  "LayoutUpdate",
@@ -16,15 +15,15 @@ var names = [
16
15
  "Unmount",
17
16
  ];
18
17
  function createLifecycles() {
19
- var managers = names.map(function () { return new SubscriptionManager(); });
20
- var propSubscriptions = {};
21
- var lifecycles = {
22
- clearAllListeners: function () { return managers.forEach(function (manager) { return manager.clear(); }); },
23
- updatePropListeners: function (props) {
24
- names.forEach(function (name) {
18
+ const managers = names.map(() => new SubscriptionManager());
19
+ const propSubscriptions = {};
20
+ const lifecycles = {
21
+ clearAllListeners: () => managers.forEach((manager) => manager.clear()),
22
+ updatePropListeners: (props) => {
23
+ names.forEach((name) => {
25
24
  var _a;
26
- var on = "on" + name;
27
- var propListener = props[on];
25
+ const on = "on" + name;
26
+ const propListener = props[on];
28
27
  // Unsubscribe existing subscription
29
28
  (_a = propSubscriptions[name]) === null || _a === void 0 ? void 0 : _a.call(propSubscriptions);
30
29
  // Add new subscription
@@ -34,15 +33,9 @@ function createLifecycles() {
34
33
  });
35
34
  },
36
35
  };
37
- managers.forEach(function (manager, i) {
38
- lifecycles["on" + names[i]] = function (handler) { return manager.add(handler); };
39
- lifecycles["notify" + names[i]] = function () {
40
- var args = [];
41
- for (var _i = 0; _i < arguments.length; _i++) {
42
- args[_i] = arguments[_i];
43
- }
44
- return manager.notify.apply(manager, __spreadArray([], __read(args), false));
45
- };
36
+ managers.forEach((manager, i) => {
37
+ lifecycles["on" + names[i]] = (handler) => manager.add(handler);
38
+ lifecycles["notify" + names[i]] = (...args) => manager.notify(...args);
46
39
  });
47
40
  return lifecycles;
48
41
  }
@@ -1,32 +1,40 @@
1
+ import { isWillChangeMotionValue } from '../../value/use-will-change/is.mjs';
1
2
  import { warnOnce } from '../../utils/warn-once.mjs';
2
3
  import { motionValue } from '../../value/index.mjs';
3
4
  import { isMotionValue } from '../../value/utils/is-motion-value.mjs';
4
5
 
5
6
  function updateMotionValuesFromProps(element, next, prev) {
6
7
  var _a;
7
- for (var key in next) {
8
- var nextValue = next[key];
9
- var prevValue = prev[key];
8
+ const { willChange } = next;
9
+ for (const key in next) {
10
+ const nextValue = next[key];
11
+ const prevValue = prev[key];
10
12
  if (isMotionValue(nextValue)) {
11
13
  /**
12
14
  * If this is a motion value found in props or style, we want to add it
13
15
  * to our visual element's motion value map.
14
16
  */
15
17
  element.addValue(key, nextValue);
18
+ if (isWillChangeMotionValue(willChange)) {
19
+ willChange.add(key);
20
+ }
16
21
  /**
17
22
  * Check the version of the incoming motion value with this version
18
23
  * and warn against mismatches.
19
24
  */
20
25
  if (process.env.NODE_ENV === "development") {
21
- warnOnce(nextValue.version === "7.0.3", "Attempting to mix Framer Motion versions ".concat(nextValue.version, " with 7.0.3 may not work as expected."));
26
+ warnOnce(nextValue.version === "7.1.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.1.2 may not work as expected.`);
22
27
  }
23
28
  }
24
29
  else if (isMotionValue(prevValue)) {
25
30
  /**
26
- * If we're swapping to a new motion value, create a new motion value
27
- * from that
31
+ * If we're swapping from a motion value to a static value,
32
+ * create a new motion value from that
28
33
  */
29
34
  element.addValue(key, motionValue(nextValue));
35
+ if (isWillChangeMotionValue(willChange)) {
36
+ willChange.remove(key);
37
+ }
30
38
  }
31
39
  else if (prevValue !== nextValue) {
32
40
  /**
@@ -35,7 +43,7 @@ function updateMotionValuesFromProps(element, next, prev) {
35
43
  * not handling the value with our animation state.
36
44
  */
37
45
  if (element.hasValue(key)) {
38
- var existingValue = element.getValue(key);
46
+ const existingValue = element.getValue(key);
39
47
  // TODO: Only update values that aren't being animated or even looked at
40
48
  !existingValue.hasAnimated && existingValue.set(nextValue);
41
49
  }
@@ -45,7 +53,7 @@ function updateMotionValuesFromProps(element, next, prev) {
45
53
  }
46
54
  }
47
55
  // Handle removed values
48
- for (var key in prev) {
56
+ for (const key in prev) {
49
57
  if (next[key] === undefined)
50
58
  element.removeValue(key);
51
59
  }
@@ -1,4 +1,4 @@
1
- import { __rest, __assign, __spreadArray, __read } from 'tslib';
1
+ import { __rest } from 'tslib';
2
2
  import { complex } from 'style-value-types';
3
3
  import { isNumericalString } from '../../utils/is-numerical-string.mjs';
4
4
  import { isZeroValueString } from '../../utils/is-zero-value-string.mjs';
@@ -21,21 +21,21 @@ function setMotionValue(visualElement, key, value) {
21
21
  }
22
22
  }
23
23
  function setTarget(visualElement, definition) {
24
- var resolved = resolveVariant(visualElement, definition);
25
- var _a = resolved ? visualElement.makeTargetAnimatable(resolved, false) : {}, _b = _a.transitionEnd, transitionEnd = _b === void 0 ? {} : _b; _a.transition; var target = __rest(_a, ["transitionEnd", "transition"]);
26
- target = __assign(__assign({}, target), transitionEnd);
27
- for (var key in target) {
28
- var value = resolveFinalValueInKeyframes(target[key]);
24
+ const resolved = resolveVariant(visualElement, definition);
25
+ let _a = resolved ? visualElement.makeTargetAnimatable(resolved, false) : {}, { transitionEnd = {}, transition = {} } = _a, target = __rest(_a, ["transitionEnd", "transition"]);
26
+ target = Object.assign(Object.assign({}, target), transitionEnd);
27
+ for (const key in target) {
28
+ const value = resolveFinalValueInKeyframes(target[key]);
29
29
  setMotionValue(visualElement, key, value);
30
30
  }
31
31
  }
32
32
  function setVariants(visualElement, variantLabels) {
33
- var reversedLabels = __spreadArray([], __read(variantLabels), false).reverse();
34
- reversedLabels.forEach(function (key) {
33
+ const reversedLabels = [...variantLabels].reverse();
34
+ reversedLabels.forEach((key) => {
35
35
  var _a;
36
- var variant = visualElement.getVariant(key);
36
+ const variant = visualElement.getVariant(key);
37
37
  variant && setTarget(visualElement, variant);
38
- (_a = visualElement.variantChildren) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {
38
+ (_a = visualElement.variantChildren) === null || _a === void 0 ? void 0 : _a.forEach((child) => {
39
39
  setVariants(child, variantLabels);
40
40
  });
41
41
  });
@@ -54,14 +54,14 @@ function setValues(visualElement, definition) {
54
54
  function checkTargetForNewValues(visualElement, target, origin) {
55
55
  var _a, _b, _c;
56
56
  var _d;
57
- var newValueKeys = Object.keys(target).filter(function (key) { return !visualElement.hasValue(key); });
58
- var numNewValues = newValueKeys.length;
57
+ const newValueKeys = Object.keys(target).filter((key) => !visualElement.hasValue(key));
58
+ const numNewValues = newValueKeys.length;
59
59
  if (!numNewValues)
60
60
  return;
61
- for (var i = 0; i < numNewValues; i++) {
62
- var key = newValueKeys[i];
63
- var targetValue = target[key];
64
- var value = null;
61
+ for (let i = 0; i < numNewValues; i++) {
62
+ const key = newValueKeys[i];
63
+ const targetValue = target[key];
64
+ let value = null;
65
65
  /**
66
66
  * If the target is a series of keyframes, we can use the first value
67
67
  * in the array. If this first value is null, we'll still need to read from the DOM.
@@ -99,13 +99,13 @@ function checkTargetForNewValues(visualElement, target, origin) {
99
99
  function getOriginFromTransition(key, transition) {
100
100
  if (!transition)
101
101
  return;
102
- var valueTransition = transition[key] || transition["default"] || transition;
102
+ const valueTransition = transition[key] || transition["default"] || transition;
103
103
  return valueTransition.from;
104
104
  }
105
105
  function getOrigin(target, transition, visualElement) {
106
106
  var _a, _b;
107
- var origin = {};
108
- for (var key in target) {
107
+ const origin = {};
108
+ for (const key in target) {
109
109
  origin[key] =
110
110
  (_a = getOriginFromTransition(key, transition)) !== null && _a !== void 0 ? _a : (_b = visualElement.getValue(key)) === null || _b === void 0 ? void 0 : _b.get();
111
111
  }
@@ -14,22 +14,20 @@ function isVariantLabel(v) {
14
14
  * Creates an object containing the latest state of every MotionValue on a VisualElement
15
15
  */
16
16
  function getCurrent(visualElement) {
17
- var current = {};
18
- visualElement.forEachValue(function (value, key) { return (current[key] = value.get()); });
17
+ const current = {};
18
+ visualElement.forEachValue((value, key) => (current[key] = value.get()));
19
19
  return current;
20
20
  }
21
21
  /**
22
22
  * Creates an object containing the latest velocity of every MotionValue on a VisualElement
23
23
  */
24
24
  function getVelocity(visualElement) {
25
- var velocity = {};
26
- visualElement.forEachValue(function (value, key) { return (velocity[key] = value.getVelocity()); });
25
+ const velocity = {};
26
+ visualElement.forEachValue((value, key) => (velocity[key] = value.getVelocity()));
27
27
  return velocity;
28
28
  }
29
- function resolveVariantFromProps(props, definition, custom, currentValues, currentVelocity) {
29
+ function resolveVariantFromProps(props, definition, custom, currentValues = {}, currentVelocity = {}) {
30
30
  var _a;
31
- if (currentValues === void 0) { currentValues = {}; }
32
- if (currentVelocity === void 0) { currentVelocity = {}; }
33
31
  /**
34
32
  * If the variant definition is a function, resolve.
35
33
  */
@@ -54,7 +52,7 @@ function resolveVariantFromProps(props, definition, custom, currentValues, curre
54
52
  return definition;
55
53
  }
56
54
  function resolveVariant(visualElement, definition, custom) {
57
- var props = visualElement.getProps();
55
+ const props = visualElement.getProps();
58
56
  return resolveVariantFromProps(props, definition, custom !== null && custom !== void 0 ? custom : props.custom, getCurrent(visualElement), getVelocity(visualElement));
59
57
  }
60
58
  function checkIfControllingVariants(props) {
@@ -1,19 +1,18 @@
1
- import { __read } from 'tslib';
2
-
3
1
  function addUniqueItem(arr, item) {
4
- arr.indexOf(item) === -1 && arr.push(item);
2
+ if (arr.indexOf(item) === -1)
3
+ arr.push(item);
5
4
  }
6
5
  function removeItem(arr, item) {
7
- var index = arr.indexOf(item);
8
- index > -1 && arr.splice(index, 1);
6
+ const index = arr.indexOf(item);
7
+ if (index > -1)
8
+ arr.splice(index, 1);
9
9
  }
10
10
  // Adapted from array-move
11
- function moveItem(_a, fromIndex, toIndex) {
12
- var _b = __read(_a), arr = _b.slice(0);
13
- var startIndex = fromIndex < 0 ? arr.length + fromIndex : fromIndex;
11
+ function moveItem([...arr], fromIndex, toIndex) {
12
+ const startIndex = fromIndex < 0 ? arr.length + fromIndex : fromIndex;
14
13
  if (startIndex >= 0 && startIndex < arr.length) {
15
- var endIndex = toIndex < 0 ? arr.length + toIndex : toIndex;
16
- var _c = __read(arr.splice(fromIndex, 1), 1), item = _c[0];
14
+ const endIndex = toIndex < 0 ? arr.length + toIndex : toIndex;
15
+ const [item] = arr.splice(fromIndex, 1);
17
16
  arr.splice(endIndex, 0, item);
18
17
  }
19
18
  return arr;
@@ -1,3 +1,3 @@
1
- var isBrowser = typeof document !== "undefined";
1
+ const isBrowser = typeof document !== "undefined";
2
2
 
3
3
  export { isBrowser };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Check if value is a numerical string, ie a string that is purely a number eg "100" or "-100.1"
3
3
  */
4
- var isNumericalString = function (v) { return /^\-?\d*\.?\d+$/.test(v); };
4
+ const isNumericalString = (v) => /^\-?\d*\.?\d+$/.test(v);
5
5
 
6
6
  export { isNumericalString };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Check if the value is a zero value string like "0px" or "0%"
3
3
  */
4
- var isZeroValueString = function (v) { return /^0[^.\s]+$/.test(v); };
4
+ const isZeroValueString = (v) => /^0[^.\s]+$/.test(v);
5
5
 
6
6
  export { isZeroValueString };
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Browser-safe usage of process
3
3
  */
4
- var defaultEnvironment = "production";
5
- var env = typeof process === "undefined" || process.env === undefined
4
+ const defaultEnvironment = "production";
5
+ const env = typeof process === "undefined" || process.env === undefined
6
6
  ? defaultEnvironment
7
7
  : process.env.NODE_ENV || defaultEnvironment;
8
8
 
@@ -1,9 +1,9 @@
1
1
  import { isKeyframesTarget } from '../animation/utils/is-keyframes-target.mjs';
2
2
 
3
- var isCustomValue = function (v) {
3
+ const isCustomValue = (v) => {
4
4
  return Boolean(v && typeof v === "object" && v.mix && v.toValue);
5
5
  };
6
- var resolveFinalValueInKeyframes = function (v) {
6
+ const resolveFinalValueInKeyframes = (v) => {
7
7
  // TODO maybe throw if v.length - 1 is placeholder token?
8
8
  return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
9
9
  };
@@ -1,10 +1,10 @@
1
1
  function shallowCompare(next, prev) {
2
2
  if (!Array.isArray(prev))
3
3
  return false;
4
- var prevLength = prev.length;
4
+ const prevLength = prev.length;
5
5
  if (prevLength !== next.length)
6
6
  return false;
7
- for (var i = 0; i < prevLength; i++) {
7
+ for (let i = 0; i < prevLength; i++) {
8
8
  if (prev[i] !== next[i])
9
9
  return false;
10
10
  }
@@ -1,16 +1,15 @@
1
1
  import { addUniqueItem, removeItem } from './array.mjs';
2
2
 
3
- var SubscriptionManager = /** @class */ (function () {
4
- function SubscriptionManager() {
3
+ class SubscriptionManager {
4
+ constructor() {
5
5
  this.subscriptions = [];
6
6
  }
7
- SubscriptionManager.prototype.add = function (handler) {
8
- var _this = this;
7
+ add(handler) {
9
8
  addUniqueItem(this.subscriptions, handler);
10
- return function () { return removeItem(_this.subscriptions, handler); };
11
- };
12
- SubscriptionManager.prototype.notify = function (a, b, c) {
13
- var numSubscriptions = this.subscriptions.length;
9
+ return () => removeItem(this.subscriptions, handler);
10
+ }
11
+ notify(a, b, c) {
12
+ const numSubscriptions = this.subscriptions.length;
14
13
  if (!numSubscriptions)
15
14
  return;
16
15
  if (numSubscriptions === 1) {
@@ -20,23 +19,22 @@ var SubscriptionManager = /** @class */ (function () {
20
19
  this.subscriptions[0](a, b, c);
21
20
  }
22
21
  else {
23
- for (var i = 0; i < numSubscriptions; i++) {
22
+ for (let i = 0; i < numSubscriptions; i++) {
24
23
  /**
25
24
  * Check whether the handler exists before firing as it's possible
26
25
  * the subscriptions were modified during this loop running.
27
26
  */
28
- var handler = this.subscriptions[i];
27
+ const handler = this.subscriptions[i];
29
28
  handler && handler(a, b, c);
30
29
  }
31
30
  }
32
- };
33
- SubscriptionManager.prototype.getSize = function () {
31
+ }
32
+ getSize() {
34
33
  return this.subscriptions.length;
35
- };
36
- SubscriptionManager.prototype.clear = function () {
34
+ }
35
+ clear() {
37
36
  this.subscriptions.length = 0;
38
- };
39
- return SubscriptionManager;
40
- }());
37
+ }
38
+ }
41
39
 
42
40
  export { SubscriptionManager };
@@ -4,6 +4,6 @@
4
4
  * @param seconds - Time in seconds.
5
5
  * @return milliseconds - Converted time in milliseconds.
6
6
  */
7
- var secondsToMilliseconds = function (seconds) { return seconds * 1000; };
7
+ const secondsToMilliseconds = (seconds) => seconds * 1000;
8
8
 
9
9
  export { secondsToMilliseconds };