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,22 +1,17 @@
1
- import { __assign } from 'tslib';
2
1
  import { interpolate } from 'popmotion';
3
2
 
4
- var isCustomValueType = function (v) {
3
+ const isCustomValueType = (v) => {
5
4
  return typeof v === "object" && v.mix;
6
5
  };
7
- var getMixer = function (v) { return (isCustomValueType(v) ? v.mix : undefined); };
8
- function transform() {
9
- var args = [];
10
- for (var _i = 0; _i < arguments.length; _i++) {
11
- args[_i] = arguments[_i];
12
- }
13
- var useImmediate = !Array.isArray(args[0]);
14
- var argOffset = useImmediate ? 0 : -1;
15
- var inputValue = args[0 + argOffset];
16
- var inputRange = args[1 + argOffset];
17
- var outputRange = args[2 + argOffset];
18
- var options = args[3 + argOffset];
19
- var interpolator = interpolate(inputRange, outputRange, __assign({ mixer: getMixer(outputRange[0]) }, options));
6
+ const getMixer = (v) => (isCustomValueType(v) ? v.mix : undefined);
7
+ function transform(...args) {
8
+ const useImmediate = !Array.isArray(args[0]);
9
+ const argOffset = useImmediate ? 0 : -1;
10
+ const inputValue = args[0 + argOffset];
11
+ const inputRange = args[1 + argOffset];
12
+ const outputRange = args[2 + argOffset];
13
+ const options = args[3 + argOffset];
14
+ const interpolator = interpolate(inputRange, outputRange, Object.assign({ mixer: getMixer(outputRange[0]) }, options));
20
15
  return useImmediate ? interpolator(inputValue) : interpolator;
21
16
  }
22
17
 
@@ -3,19 +3,18 @@ import { useRef, useContext, useEffect } from 'react';
3
3
  import { MotionConfigContext } from '../context/MotionConfigContext.mjs';
4
4
 
5
5
  function useAnimationFrame(callback) {
6
- var initialTimestamp = useRef(0);
7
- var isStatic = useContext(MotionConfigContext).isStatic;
8
- useEffect(function () {
6
+ const initialTimestamp = useRef(0);
7
+ const { isStatic } = useContext(MotionConfigContext);
8
+ useEffect(() => {
9
9
  if (isStatic)
10
10
  return;
11
- var provideTimeSinceStart = function (_a) {
12
- var timestamp = _a.timestamp;
11
+ const provideTimeSinceStart = ({ timestamp }) => {
13
12
  if (!initialTimestamp.current)
14
13
  initialTimestamp.current = timestamp;
15
14
  callback(timestamp - initialTimestamp.current);
16
15
  };
17
16
  sync.update(provideTimeSinceStart, true);
18
- return function () { return cancelSync.update(provideTimeSinceStart); };
17
+ return () => cancelSync.update(provideTimeSinceStart);
19
18
  }, [callback]);
20
19
  }
21
20
 
@@ -8,7 +8,7 @@ import { useRef } from 'react';
8
8
  * you can ensure that initialisers don't execute twice or more.
9
9
  */
10
10
  function useConstant(init) {
11
- var ref = useRef(null);
11
+ const ref = useRef(null);
12
12
  if (ref.current === null) {
13
13
  ref.current = init();
14
14
  }
@@ -1,4 +1,3 @@
1
- import { __read, __spreadArray } from 'tslib';
2
1
  import { wrap } from 'popmotion';
3
2
  import { useRef, useState, useCallback } from 'react';
4
3
 
@@ -28,20 +27,20 @@ import { useRef, useState, useCallback } from 'react';
28
27
  *
29
28
  * @public
30
29
  */
31
- function useCycle() {
32
- var items = [];
33
- for (var _i = 0; _i < arguments.length; _i++) {
34
- items[_i] = arguments[_i];
35
- }
36
- var index = useRef(0);
37
- var _a = __read(useState(items[index.current]), 2), item = _a[0], setItem = _a[1];
38
- var runCycle = useCallback(function (next) {
30
+ function useCycle(...items) {
31
+ const index = useRef(0);
32
+ const [item, setItem] = useState(items[index.current]);
33
+ const runCycle = useCallback((next) => {
39
34
  index.current =
40
35
  typeof next !== "number"
41
36
  ? wrap(0, items.length, index.current + 1)
42
37
  : next;
43
38
  setItem(items[index.current]);
44
- }, __spreadArray([items.length], __read(items), false));
39
+ },
40
+ // The array will change on each call, but by putting items.length at
41
+ // the front of this array, we guarantee the dependency comparison will match up
42
+ // eslint-disable-next-line react-hooks/exhaustive-deps
43
+ [items.length, ...items]);
45
44
  return [item, runCycle];
46
45
  }
47
46
 
@@ -1,19 +1,18 @@
1
- import { __read } from 'tslib';
2
1
  import sync from 'framesync';
3
2
  import { useState, useCallback } from 'react';
4
3
  import { useIsMounted } from './use-is-mounted.mjs';
5
4
 
6
5
  function useForceUpdate() {
7
- var isMounted = useIsMounted();
8
- var _a = __read(useState(0), 2), forcedRenderCount = _a[0], setForcedRenderCount = _a[1];
9
- var forceRender = useCallback(function () {
6
+ const isMounted = useIsMounted();
7
+ const [forcedRenderCount, setForcedRenderCount] = useState(0);
8
+ const forceRender = useCallback(() => {
10
9
  isMounted.current && setForcedRenderCount(forcedRenderCount + 1);
11
10
  }, [forcedRenderCount]);
12
11
  /**
13
12
  * Defer this to the end of the next animation frame in case there are multiple
14
13
  * synchronous calls.
15
14
  */
16
- var deferredForceRender = useCallback(function () { return sync.postRender(forceRender); }, [forceRender]);
15
+ const deferredForceRender = useCallback(() => sync.postRender(forceRender), [forceRender]);
17
16
  return [deferredForceRender, forcedRenderCount];
18
17
  }
19
18
 
@@ -1,21 +1,19 @@
1
- import { __read } from 'tslib';
2
1
  import { useState, useEffect } from 'react';
3
2
  import { inView } from '@motionone/dom';
4
3
 
5
- function useInView(ref, _a) {
6
- var _b = _a === void 0 ? {} : _a, root = _b.root, margin = _b.margin, amount = _b.amount, _c = _b.once, once = _c === void 0 ? false : _c;
7
- var _d = __read(useState(false), 2), isInView = _d[0], setInView = _d[1];
8
- useEffect(function () {
4
+ function useInView(ref, { root, margin, amount, once = false } = {}) {
5
+ const [isInView, setInView] = useState(false);
6
+ useEffect(() => {
9
7
  var _a;
10
8
  if (!ref.current || (once && isInView))
11
9
  return;
12
- var onEnter = function () {
10
+ const onEnter = () => {
13
11
  setInView(true);
14
- return once ? undefined : function () { return setInView(false); };
12
+ return once ? undefined : () => setInView(false);
15
13
  };
16
- var options = {
14
+ const options = {
17
15
  root: (_a = root === null || root === void 0 ? void 0 : root.current) !== null && _a !== void 0 ? _a : undefined,
18
- margin: margin,
16
+ margin,
19
17
  amount: amount === "some" ? "any" : amount,
20
18
  };
21
19
  return inView(ref.current, onEnter, options);
@@ -1,4 +1,4 @@
1
- var instantAnimationState = {
1
+ const instantAnimationState = {
2
2
  current: false,
3
3
  };
4
4
 
@@ -1,4 +1,3 @@
1
- import { __read } from 'tslib';
2
1
  import sync from 'framesync';
3
2
  import { useEffect } from 'react';
4
3
  import { useInstantLayoutTransition } from '../projection/use-instant-layout-transition.mjs';
@@ -6,18 +5,16 @@ import { useForceUpdate } from './use-force-update.mjs';
6
5
  import { instantAnimationState } from './use-instant-transition-state.mjs';
7
6
 
8
7
  function useInstantTransition() {
9
- var _a = __read(useForceUpdate(), 2), forceUpdate = _a[0], forcedRenderCount = _a[1];
10
- var startInstantLayoutTransition = useInstantLayoutTransition();
11
- useEffect(function () {
8
+ const [forceUpdate, forcedRenderCount] = useForceUpdate();
9
+ const startInstantLayoutTransition = useInstantLayoutTransition();
10
+ useEffect(() => {
12
11
  /**
13
12
  * Unblock after two animation frames, otherwise this will unblock too soon.
14
13
  */
15
- sync.postRender(function () {
16
- return sync.postRender(function () { return (instantAnimationState.current = false); });
17
- });
14
+ sync.postRender(() => sync.postRender(() => (instantAnimationState.current = false)));
18
15
  }, [forcedRenderCount]);
19
- return function (callback) {
20
- startInstantLayoutTransition(function () {
16
+ return (callback) => {
17
+ startInstantLayoutTransition(() => {
21
18
  instantAnimationState.current = true;
22
19
  forceUpdate();
23
20
  callback();
@@ -2,10 +2,10 @@ import { useRef } from 'react';
2
2
  import { useIsomorphicLayoutEffect } from './use-isomorphic-effect.mjs';
3
3
 
4
4
  function useIsMounted() {
5
- var isMounted = useRef(false);
6
- useIsomorphicLayoutEffect(function () {
5
+ const isMounted = useRef(false);
6
+ useIsomorphicLayoutEffect(() => {
7
7
  isMounted.current = true;
8
- return function () {
8
+ return () => {
9
9
  isMounted.current = false;
10
10
  };
11
11
  }, []);
@@ -1,6 +1,6 @@
1
1
  import { useLayoutEffect, useEffect } from 'react';
2
2
  import { isBrowser } from './is-browser.mjs';
3
3
 
4
- var useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : useEffect;
4
+ const useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : useEffect;
5
5
 
6
6
  export { useIsomorphicLayoutEffect };
@@ -1,21 +1,18 @@
1
- import { __read } from 'tslib';
2
1
  import { useState, useContext } from 'react';
3
2
  import { MotionConfigContext } from '../context/MotionConfigContext.mjs';
4
3
  import { isBrowser } from './is-browser.mjs';
5
4
 
6
5
  // Does this device prefer reduced motion? Returns `null` server-side.
7
- var prefersReducedMotion = { current: null };
8
- var hasDetected = false;
6
+ const prefersReducedMotion = { current: null };
7
+ let hasDetected = false;
9
8
  function initPrefersReducedMotion() {
10
9
  hasDetected = true;
11
10
  if (!isBrowser)
12
11
  return;
13
12
  if (window.matchMedia) {
14
- var motionMediaQuery_1 = window.matchMedia("(prefers-reduced-motion)");
15
- var setReducedMotionPreferences = function () {
16
- return (prefersReducedMotion.current = motionMediaQuery_1.matches);
17
- };
18
- motionMediaQuery_1.addListener(setReducedMotionPreferences);
13
+ const motionMediaQuery = window.matchMedia("(prefers-reduced-motion)");
14
+ const setReducedMotionPreferences = () => (prefersReducedMotion.current = motionMediaQuery.matches);
15
+ motionMediaQuery.addListener(setReducedMotionPreferences);
19
16
  setReducedMotionPreferences();
20
17
  }
21
18
  else {
@@ -53,15 +50,15 @@ function useReducedMotion() {
53
50
  * Lazy initialisation of prefersReducedMotion
54
51
  */
55
52
  !hasDetected && initPrefersReducedMotion();
56
- var _a = __read(useState(prefersReducedMotion.current), 1), shouldReduceMotion = _a[0];
53
+ const [shouldReduceMotion] = useState(prefersReducedMotion.current);
57
54
  /**
58
55
  * TODO See if people miss automatically updating shouldReduceMotion setting
59
56
  */
60
57
  return shouldReduceMotion;
61
58
  }
62
59
  function useReducedMotionConfig() {
63
- var reducedMotionPreference = useReducedMotion();
64
- var reducedMotion = useContext(MotionConfigContext).reducedMotion;
60
+ const reducedMotionPreference = useReducedMotion();
61
+ const { reducedMotion } = useContext(MotionConfigContext);
65
62
  if (reducedMotion === "never") {
66
63
  return false;
67
64
  }
@@ -1,7 +1,7 @@
1
1
  import { useEffect } from 'react';
2
2
 
3
3
  function useUnmountEffect(callback) {
4
- return useEffect(function () { return function () { return callback(); }; }, []);
4
+ return useEffect(() => () => callback(), []);
5
5
  }
6
6
 
7
7
  export { useUnmountEffect };
@@ -1,4 +1,4 @@
1
- var warned = new Set();
1
+ const warned = new Set();
2
2
  function warnOnce(condition, message, element) {
3
3
  if (condition || warned.has(message))
4
4
  return;
@@ -2,7 +2,7 @@ import sync, { getFrameData } from 'framesync';
2
2
  import { velocityPerSecond } from 'popmotion';
3
3
  import { SubscriptionManager } from '../utils/subscription-manager.mjs';
4
4
 
5
- var isFloat = function (value) {
5
+ const isFloat = (value) => {
6
6
  return !isNaN(parseFloat(value));
7
7
  };
8
8
  /**
@@ -10,7 +10,7 @@ var isFloat = function (value) {
10
10
  *
11
11
  * @public
12
12
  */
13
- var MotionValue = /** @class */ (function () {
13
+ class MotionValue {
14
14
  /**
15
15
  * @param init - The initiating value
16
16
  * @param config - Optional configuration options
@@ -19,13 +19,12 @@ var MotionValue = /** @class */ (function () {
19
19
  *
20
20
  * @internal
21
21
  */
22
- function MotionValue(init) {
23
- var _this = this;
22
+ constructor(init) {
24
23
  /**
25
24
  * This will be replaced by the build step with the latest version number.
26
25
  * When MotionValues are provided to motion components, warn if versions are mixed.
27
26
  */
28
- this.version = "7.0.3";
27
+ this.version = "7.1.2";
29
28
  /**
30
29
  * Duration, in milliseconds, since last updating frame.
31
30
  *
@@ -64,28 +63,27 @@ var MotionValue = /** @class */ (function () {
64
63
  * @internal
65
64
  */
66
65
  this.canTrackVelocity = false;
67
- this.updateAndNotify = function (v, render) {
68
- if (render === void 0) { render = true; }
69
- _this.prev = _this.current;
70
- _this.current = v;
66
+ this.updateAndNotify = (v, render = true) => {
67
+ this.prev = this.current;
68
+ this.current = v;
71
69
  // Update timestamp
72
- var _a = getFrameData(), delta = _a.delta, timestamp = _a.timestamp;
73
- if (_this.lastUpdated !== timestamp) {
74
- _this.timeDelta = delta;
75
- _this.lastUpdated = timestamp;
76
- sync.postRender(_this.scheduleVelocityCheck);
70
+ const { delta, timestamp } = getFrameData();
71
+ if (this.lastUpdated !== timestamp) {
72
+ this.timeDelta = delta;
73
+ this.lastUpdated = timestamp;
74
+ sync.postRender(this.scheduleVelocityCheck);
77
75
  }
78
76
  // Update update subscribers
79
- if (_this.prev !== _this.current) {
80
- _this.updateSubscribers.notify(_this.current);
77
+ if (this.prev !== this.current) {
78
+ this.updateSubscribers.notify(this.current);
81
79
  }
82
80
  // Update velocity subscribers
83
- if (_this.velocityUpdateSubscribers.getSize()) {
84
- _this.velocityUpdateSubscribers.notify(_this.getVelocity());
81
+ if (this.velocityUpdateSubscribers.getSize()) {
82
+ this.velocityUpdateSubscribers.notify(this.getVelocity());
85
83
  }
86
84
  // Update render subscribers
87
85
  if (render) {
88
- _this.renderSubscribers.notify(_this.current);
86
+ this.renderSubscribers.notify(this.current);
89
87
  }
90
88
  };
91
89
  /**
@@ -96,7 +94,7 @@ var MotionValue = /** @class */ (function () {
96
94
  *
97
95
  * @internal
98
96
  */
99
- this.scheduleVelocityCheck = function () { return sync.postRender(_this.velocityCheck); };
97
+ this.scheduleVelocityCheck = () => sync.postRender(this.velocityCheck);
100
98
  /**
101
99
  * Updates `prev` with `current` if the value hasn't been updated this frame.
102
100
  * This ensures velocity calculations return `0`.
@@ -106,11 +104,10 @@ var MotionValue = /** @class */ (function () {
106
104
  *
107
105
  * @internal
108
106
  */
109
- this.velocityCheck = function (_a) {
110
- var timestamp = _a.timestamp;
111
- if (timestamp !== _this.lastUpdated) {
112
- _this.prev = _this.current;
113
- _this.velocityUpdateSubscribers.notify(_this.getVelocity());
107
+ this.velocityCheck = ({ timestamp }) => {
108
+ if (timestamp !== this.lastUpdated) {
109
+ this.prev = this.current;
110
+ this.velocityUpdateSubscribers.notify(this.getVelocity());
114
111
  }
115
112
  };
116
113
  this.hasAnimated = false;
@@ -165,12 +162,12 @@ var MotionValue = /** @class */ (function () {
165
162
  *
166
163
  * @public
167
164
  */
168
- MotionValue.prototype.onChange = function (subscription) {
165
+ onChange(subscription) {
169
166
  return this.updateSubscribers.add(subscription);
170
- };
171
- MotionValue.prototype.clearListeners = function () {
167
+ }
168
+ clearListeners() {
172
169
  this.updateSubscribers.clear();
173
- };
170
+ }
174
171
  /**
175
172
  * Adds a function that will be notified when the `MotionValue` requests a render.
176
173
  *
@@ -179,19 +176,19 @@ var MotionValue = /** @class */ (function () {
179
176
  *
180
177
  * @internal
181
178
  */
182
- MotionValue.prototype.onRenderRequest = function (subscription) {
179
+ onRenderRequest(subscription) {
183
180
  // Render immediately
184
181
  subscription(this.get());
185
182
  return this.renderSubscribers.add(subscription);
186
- };
183
+ }
187
184
  /**
188
185
  * Attaches a passive effect to the `MotionValue`.
189
186
  *
190
187
  * @internal
191
188
  */
192
- MotionValue.prototype.attach = function (passiveEffect) {
189
+ attach(passiveEffect) {
193
190
  this.passiveEffect = passiveEffect;
194
- };
191
+ }
195
192
  /**
196
193
  * Sets the state of the `MotionValue`.
197
194
  *
@@ -207,15 +204,14 @@ var MotionValue = /** @class */ (function () {
207
204
  *
208
205
  * @public
209
206
  */
210
- MotionValue.prototype.set = function (v, render) {
211
- if (render === void 0) { render = true; }
207
+ set(v, render = true) {
212
208
  if (!render || !this.passiveEffect) {
213
209
  this.updateAndNotify(v, render);
214
210
  }
215
211
  else {
216
212
  this.passiveEffect(v, this.updateAndNotify);
217
213
  }
218
- };
214
+ }
219
215
  /**
220
216
  * Returns the latest state of `MotionValue`
221
217
  *
@@ -223,15 +219,15 @@ var MotionValue = /** @class */ (function () {
223
219
  *
224
220
  * @public
225
221
  */
226
- MotionValue.prototype.get = function () {
222
+ get() {
227
223
  return this.current;
228
- };
224
+ }
229
225
  /**
230
226
  * @public
231
227
  */
232
- MotionValue.prototype.getPrevious = function () {
228
+ getPrevious() {
233
229
  return this.prev;
234
- };
230
+ }
235
231
  /**
236
232
  * Returns the latest velocity of `MotionValue`
237
233
  *
@@ -239,14 +235,14 @@ var MotionValue = /** @class */ (function () {
239
235
  *
240
236
  * @public
241
237
  */
242
- MotionValue.prototype.getVelocity = function () {
238
+ getVelocity() {
243
239
  // This could be isFloat(this.prev) && isFloat(this.current), but that would be wasteful
244
240
  return this.canTrackVelocity
245
241
  ? // These casts could be avoided if parseFloat would be typed better
246
242
  velocityPerSecond(parseFloat(this.current) -
247
243
  parseFloat(this.prev), this.timeDelta)
248
244
  : 0;
249
- };
245
+ }
250
246
  /**
251
247
  * Registers a new animation to control this `MotionValue`. Only one
252
248
  * animation can drive a `MotionValue` at one time.
@@ -259,35 +255,34 @@ var MotionValue = /** @class */ (function () {
259
255
  *
260
256
  * @internal
261
257
  */
262
- MotionValue.prototype.start = function (animation) {
263
- var _this = this;
258
+ start(animation) {
264
259
  this.stop();
265
- return new Promise(function (resolve) {
266
- _this.hasAnimated = true;
267
- _this.stopAnimation = animation(resolve);
268
- }).then(function () { return _this.clearAnimation(); });
269
- };
260
+ return new Promise((resolve) => {
261
+ this.hasAnimated = true;
262
+ this.stopAnimation = animation(resolve);
263
+ }).then(() => this.clearAnimation());
264
+ }
270
265
  /**
271
266
  * Stop the currently active animation.
272
267
  *
273
268
  * @public
274
269
  */
275
- MotionValue.prototype.stop = function () {
270
+ stop() {
276
271
  if (this.stopAnimation)
277
272
  this.stopAnimation();
278
273
  this.clearAnimation();
279
- };
274
+ }
280
275
  /**
281
276
  * Returns `true` if this value is currently animating.
282
277
  *
283
278
  * @public
284
279
  */
285
- MotionValue.prototype.isAnimating = function () {
280
+ isAnimating() {
286
281
  return !!this.stopAnimation;
287
- };
288
- MotionValue.prototype.clearAnimation = function () {
282
+ }
283
+ clearAnimation() {
289
284
  this.stopAnimation = null;
290
- };
285
+ }
291
286
  /**
292
287
  * Destroy and clean up subscribers to this `MotionValue`.
293
288
  *
@@ -297,13 +292,12 @@ var MotionValue = /** @class */ (function () {
297
292
  *
298
293
  * @public
299
294
  */
300
- MotionValue.prototype.destroy = function () {
295
+ destroy() {
301
296
  this.updateSubscribers.clear();
302
297
  this.renderSubscribers.clear();
303
298
  this.stop();
304
- };
305
- return MotionValue;
306
- }());
299
+ }
300
+ }
307
301
  function motionValue(init) {
308
302
  return new MotionValue(init);
309
303
  }
@@ -6,14 +6,14 @@ function useCombineMotionValues(values, combineValues) {
6
6
  /**
7
7
  * Initialise the returned motion value. This remains the same between renders.
8
8
  */
9
- var value = useMotionValue(combineValues());
9
+ const value = useMotionValue(combineValues());
10
10
  /**
11
11
  * Create a function that will update the template motion value with the latest values.
12
12
  * This is pre-bound so whenever a motion value updates it can schedule its
13
13
  * execution in Framesync. If it's already been scheduled it won't be fired twice
14
14
  * in a single frame.
15
15
  */
16
- var updateValue = function () { return value.set(combineValues()); };
16
+ const updateValue = () => value.set(combineValues());
17
17
  /**
18
18
  * Synchronously update the motion value with the latest values during the render.
19
19
  * This ensures that within a React render, the styles applied to the DOM are up-to-date.
@@ -23,7 +23,7 @@ function useCombineMotionValues(values, combineValues) {
23
23
  * Subscribe to all motion values found within the template. Whenever any of them change,
24
24
  * schedule an update.
25
25
  */
26
- useMultiOnChange(values, function () { return sync.update(updateValue, false, true); });
26
+ useMultiOnChange(values, () => sync.update(updateValue, false, true));
27
27
  return value;
28
28
  }
29
29
 
@@ -6,11 +6,9 @@ import { useVisualElementContext } from '../context/MotionContext/index.mjs';
6
6
  // Keep things reasonable and avoid scale: Infinity. In practise we might need
7
7
  // to add another value, opacity, that could interpolate scaleX/Y [0,0.01] => [0,1]
8
8
  // to simply hide content at unreasonable scales.
9
- var maxScale = 100000;
10
- var invertScale = function (scale) {
11
- return scale > 0.001 ? 1 / scale : maxScale;
12
- };
13
- var hasWarned = false;
9
+ const maxScale = 100000;
10
+ const invertScale = (scale) => scale > 0.001 ? 1 / scale : maxScale;
11
+ let hasWarned = false;
14
12
  /**
15
13
  * Returns a `MotionValue` each for `scaleX` and `scaleY` that update with the inverse
16
14
  * of their respective parent scales.
@@ -31,9 +29,9 @@ var hasWarned = false;
31
29
  * @deprecated
32
30
  */
33
31
  function useInvertedScale(scale) {
34
- var parentScaleX = useMotionValue(1);
35
- var parentScaleY = useMotionValue(1);
36
- var visualElement = useVisualElementContext();
32
+ let parentScaleX = useMotionValue(1);
33
+ let parentScaleY = useMotionValue(1);
34
+ const visualElement = useVisualElementContext();
37
35
  invariant(!!(scale || visualElement), "If no scale values are provided, useInvertedScale must be used within a child of another motion component.");
38
36
  warning(hasWarned, "useInvertedScale is deprecated and will be removed in 3.0. Use the layout prop instead.");
39
37
  hasWarned = true;
@@ -45,9 +43,9 @@ function useInvertedScale(scale) {
45
43
  parentScaleX = visualElement.getValue("scaleX", 1);
46
44
  parentScaleY = visualElement.getValue("scaleY", 1);
47
45
  }
48
- var scaleX = useTransform(parentScaleX, invertScale);
49
- var scaleY = useTransform(parentScaleY, invertScale);
50
- return { scaleX: scaleX, scaleY: scaleY };
46
+ const scaleX = useTransform(parentScaleX, invertScale);
47
+ const scaleY = useTransform(parentScaleY, invertScale);
48
+ return { scaleX, scaleY };
51
49
  }
52
50
 
53
51
  export { invertScale, useInvertedScale };
@@ -22,20 +22,16 @@ import { useCombineMotionValues } from './use-combine-values.mjs';
22
22
  *
23
23
  * @public
24
24
  */
25
- function useMotionTemplate(fragments) {
26
- var values = [];
27
- for (var _i = 1; _i < arguments.length; _i++) {
28
- values[_i - 1] = arguments[_i];
29
- }
25
+ function useMotionTemplate(fragments, ...values) {
30
26
  /**
31
27
  * Create a function that will build a string from the latest motion values.
32
28
  */
33
- var numFragments = fragments.length;
29
+ const numFragments = fragments.length;
34
30
  function buildValue() {
35
- var output = "";
36
- for (var i = 0; i < numFragments; i++) {
31
+ let output = ``;
32
+ for (let i = 0; i < numFragments; i++) {
37
33
  output += fragments[i];
38
- var value = values[i];
34
+ const value = values[i];
39
35
  if (value)
40
36
  output += values[i].get();
41
37
  }