framer-motion 7.2.0 → 7.2.1

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 (95) hide show
  1. package/dist/cjs/index.js +728 -624
  2. package/dist/es/animation/use-animated-state.mjs +3 -5
  3. package/dist/es/animation/utils/default-transitions.mjs +1 -1
  4. package/dist/es/animation/utils/transitions.mjs +28 -26
  5. package/dist/es/components/AnimatePresence/PopChild.mjs +3 -2
  6. package/dist/es/components/AnimatePresence/PresenceChild.mjs +5 -2
  7. package/dist/es/components/AnimatePresence/use-presence.mjs +1 -1
  8. package/dist/es/components/LayoutGroup/index.mjs +4 -5
  9. package/dist/es/components/LazyMotion/index.mjs +3 -5
  10. package/dist/es/components/MotionConfig/index.mjs +2 -4
  11. package/dist/es/components/Reorder/Group.mjs +2 -4
  12. package/dist/es/components/Reorder/Item.mjs +6 -8
  13. package/dist/es/context/MotionContext/utils.mjs +3 -2
  14. package/dist/es/gestures/PanSession.mjs +2 -2
  15. package/dist/es/gestures/drag/VisualElementDragControls.mjs +16 -4
  16. package/dist/es/gestures/use-focus-gesture.mjs +3 -4
  17. package/dist/es/gestures/use-hover-gesture.mjs +4 -3
  18. package/dist/es/gestures/use-tap-gesture.mjs +9 -10
  19. package/dist/es/index.mjs +2 -1
  20. package/dist/es/motion/features/animations.mjs +8 -3
  21. package/dist/es/motion/features/definitions.mjs +1 -13
  22. package/dist/es/motion/features/layout/MeasureLayout.mjs +12 -6
  23. package/dist/es/motion/features/load-features.mjs +14 -0
  24. package/dist/es/motion/features/viewport/observers.mjs +4 -7
  25. package/dist/es/motion/features/viewport/use-viewport.mjs +8 -6
  26. package/dist/es/motion/index.mjs +23 -23
  27. package/dist/es/motion/utils/VisualElementHandler.mjs +2 -5
  28. package/dist/es/motion/utils/is-forced-motion-value.mjs +3 -3
  29. package/dist/es/motion/utils/use-motion-ref.mjs +1 -2
  30. package/dist/es/motion/utils/use-visual-element.mjs +14 -12
  31. package/dist/es/motion/utils/use-visual-state.mjs +19 -16
  32. package/dist/es/motion/utils/valid-prop.mjs +22 -17
  33. package/dist/es/projection/node/HTMLProjectionNode.mjs +1 -1
  34. package/dist/es/projection/node/create-projection-node.mjs +34 -16
  35. package/dist/es/projection/use-instant-layout-transition.mjs +2 -2
  36. package/dist/es/render/dom/features-animation.mjs +5 -1
  37. package/dist/es/render/dom/features-max.mjs +6 -1
  38. package/dist/es/render/dom/motion.mjs +6 -1
  39. package/dist/es/render/dom/use-render.mjs +5 -1
  40. package/dist/es/render/dom/utils/camel-to-dash.mjs +1 -3
  41. package/dist/es/render/dom/utils/create-config.mjs +7 -2
  42. package/dist/es/render/dom/utils/css-variables-conversion.mjs +5 -7
  43. package/dist/es/render/dom/utils/unit-conversion.mjs +4 -4
  44. package/dist/es/render/dom/value-types/defaults.mjs +15 -3
  45. package/dist/es/render/dom/value-types/type-int.mjs +4 -1
  46. package/dist/es/render/html/config-motion.mjs +1 -1
  47. package/dist/es/render/html/use-props.mjs +5 -9
  48. package/dist/es/render/html/utils/build-styles.mjs +17 -15
  49. package/dist/es/render/html/utils/build-transform.mjs +8 -18
  50. package/dist/es/render/html/utils/transform.mjs +20 -30
  51. package/dist/es/render/html/visual-element.mjs +8 -9
  52. package/dist/es/render/index.mjs +118 -40
  53. package/dist/es/render/svg/use-props.mjs +5 -2
  54. package/dist/es/render/svg/utils/build-attrs.mjs +3 -5
  55. package/dist/es/render/svg/utils/create-render-state.mjs +4 -1
  56. package/dist/es/render/svg/visual-element.mjs +8 -4
  57. package/dist/es/render/utils/animation-state.mjs +12 -9
  58. package/dist/es/render/utils/animation.mjs +14 -8
  59. package/dist/es/render/utils/is-controlling-variants.mjs +22 -0
  60. package/dist/es/render/utils/is-variant-label.mjs +8 -0
  61. package/dist/es/render/utils/motion-values.mjs +3 -3
  62. package/dist/es/render/utils/resolve-dynamic-variants.mjs +24 -0
  63. package/dist/es/render/utils/resolve-variants.mjs +26 -0
  64. package/dist/es/render/utils/setters.mjs +12 -9
  65. package/dist/es/utils/reduced-motion/index.mjs +19 -0
  66. package/dist/es/utils/reduced-motion/state.mjs +5 -0
  67. package/dist/es/utils/reduced-motion/use-reduced-motion-config.mjs +19 -0
  68. package/dist/es/utils/reduced-motion/use-reduced-motion.mjs +43 -0
  69. package/dist/es/utils/transform.mjs +4 -1
  70. package/dist/es/utils/use-in-view.mjs +1 -2
  71. package/dist/es/value/index.mjs +1 -1
  72. package/dist/es/value/use-scroll.mjs +6 -4
  73. package/dist/es/value/use-spring.mjs +7 -1
  74. package/dist/es/value/use-will-change/index.mjs +4 -4
  75. package/dist/es/value/utils/is-motion-value.mjs +1 -3
  76. package/dist/framer-motion.dev.js +769 -664
  77. package/dist/framer-motion.js +1 -1
  78. package/dist/index.d.ts +55 -52
  79. package/dist/projection.dev.js +368 -210
  80. package/dist/size-rollup-dom-animation-assets.js +1 -0
  81. package/dist/size-rollup-dom-animation-m.js +1 -0
  82. package/dist/size-rollup-dom-animation.js +1 -1
  83. package/dist/size-rollup-dom-max-assets.js +1 -0
  84. package/dist/size-rollup-dom-max.js +1 -1
  85. package/dist/size-rollup-m.js +1 -1
  86. package/dist/size-rollup-motion.js +1 -0
  87. package/dist/size-webpack-dom-animation.js +1 -1
  88. package/dist/size-webpack-dom-max.js +1 -1
  89. package/dist/size-webpack-m.js +1 -1
  90. package/dist/three-entry.d.ts +36 -20
  91. package/package.json +12 -8
  92. package/dist/es/motion/features/use-features.mjs +0 -40
  93. package/dist/es/motion/features/use-projection.mjs +0 -33
  94. package/dist/es/render/utils/variants.mjs +0 -73
  95. package/dist/es/utils/use-reduced-motion.mjs +0 -73
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Projection = {}));
5
- })(this, (function (exports) { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Projection = {}, global.react));
5
+ })(this, (function (exports, react) { 'use strict';
6
6
 
7
7
  const defaultTimestep = (1 / 60) * 1000;
8
8
  const getCurrentTime = typeof performance !== "undefined"
@@ -1242,7 +1242,7 @@
1242
1242
  * This will be replaced by the build step with the latest version number.
1243
1243
  * When MotionValues are provided to motion components, warn if versions are mixed.
1244
1244
  */
1245
- this.version = "7.2.0";
1245
+ this.version = "7.2.1";
1246
1246
  /**
1247
1247
  * Duration, in milliseconds, since last updating frame.
1248
1248
  *
@@ -1520,9 +1520,7 @@
1520
1520
  return new MotionValue(init);
1521
1521
  }
1522
1522
 
1523
- const isMotionValue = (value) => {
1524
- return Boolean(value !== null && typeof value === "object" && value.getVelocity);
1525
- };
1523
+ const isMotionValue = (value) => value === undefined ? false : !!value.getVelocity;
1526
1524
 
1527
1525
  /**
1528
1526
  * Converts seconds to milliseconds
@@ -1644,10 +1642,13 @@
1644
1642
  transitionFactory =
1645
1643
  defaultTransitions[valueKey] || defaultTransitions.default;
1646
1644
  }
1647
- return Object.assign({ to }, transitionFactory(to));
1645
+ return { to, ...transitionFactory(to) };
1648
1646
  };
1649
1647
 
1650
- const int = Object.assign(Object.assign({}, number), { transform: Math.round });
1648
+ const int = {
1649
+ ...number,
1650
+ transform: Math.round,
1651
+ };
1651
1652
 
1652
1653
  const numberValueTypes = {
1653
1654
  // Border props
@@ -1719,11 +1720,23 @@
1719
1720
  /**
1720
1721
  * A map of default value types for common values
1721
1722
  */
1722
- const defaultValueTypes = Object.assign(Object.assign({}, numberValueTypes), {
1723
+ const defaultValueTypes = {
1724
+ ...numberValueTypes,
1723
1725
  // Color props
1724
- color, backgroundColor: color, outlineColor: color, fill: color, stroke: color,
1726
+ color,
1727
+ backgroundColor: color,
1728
+ outlineColor: color,
1729
+ fill: color,
1730
+ stroke: color,
1725
1731
  // Border props
1726
- borderColor: color, borderTopColor: color, borderRightColor: color, borderBottomColor: color, borderLeftColor: color, filter, WebkitFilter: filter });
1732
+ borderColor: color,
1733
+ borderTopColor: color,
1734
+ borderRightColor: color,
1735
+ borderBottomColor: color,
1736
+ borderLeftColor: color,
1737
+ filter,
1738
+ WebkitFilter: filter,
1739
+ };
1727
1740
  /**
1728
1741
  * Gets the default ValueType for the provided value key
1729
1742
  */
@@ -1755,17 +1768,15 @@
1755
1768
  * This filters out orchestration options and returns true
1756
1769
  * if any options are left.
1757
1770
  */
1758
- function isTransitionDefined(_a) {
1759
- var transition = __rest(_a, ["when", "delay", "delayChildren", "staggerChildren", "staggerDirection", "repeat", "repeatType", "repeatDelay", "from"]);
1771
+ function isTransitionDefined({ when, delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, ...transition }) {
1760
1772
  return !!Object.keys(transition).length;
1761
1773
  }
1762
1774
  let legacyRepeatWarning = false;
1763
1775
  /**
1764
1776
  * Convert Framer Motion's Transition type into Popmotion-compatible options.
1765
1777
  */
1766
- function convertTransitionToAnimationOptions(_a) {
1767
- var { ease, times, yoyo, flip, loop } = _a, transition = __rest(_a, ["ease", "times", "yoyo", "flip", "loop"]);
1768
- const options = Object.assign({}, transition);
1778
+ function convertTransitionToAnimationOptions({ ease, times, yoyo, flip, loop, ...transition }) {
1779
+ const options = { ...transition };
1769
1780
  if (times)
1770
1781
  options["offset"] = times;
1771
1782
  /**
@@ -1830,26 +1841,30 @@
1830
1841
  return options;
1831
1842
  }
1832
1843
  function getPopmotionAnimationOptions(transition, options, key) {
1833
- var _a;
1834
- if (Array.isArray(options.to)) {
1835
- (_a = transition.duration) !== null && _a !== void 0 ? _a : (transition.duration = 0.8);
1844
+ if (Array.isArray(options.to) && transition.duration === undefined) {
1845
+ transition.duration = 0.8;
1836
1846
  }
1837
1847
  hydrateKeyframes(options);
1838
1848
  /**
1839
1849
  * Get a default transition if none is determined to be defined.
1840
1850
  */
1841
1851
  if (!isTransitionDefined(transition)) {
1842
- transition = Object.assign(Object.assign({}, transition), getDefaultTransition(key, options.to));
1852
+ transition = {
1853
+ ...transition,
1854
+ ...getDefaultTransition(key, options.to),
1855
+ };
1843
1856
  }
1844
- return Object.assign(Object.assign({}, options), convertTransitionToAnimationOptions(transition));
1857
+ return {
1858
+ ...options,
1859
+ ...convertTransitionToAnimationOptions(transition),
1860
+ };
1845
1861
  }
1846
1862
  /**
1847
1863
  *
1848
1864
  */
1849
1865
  function getAnimation(key, value, target, transition, onComplete) {
1850
- var _a;
1851
- const valueTransition = getValueTransition(transition, key);
1852
- let origin = (_a = valueTransition.from) !== null && _a !== void 0 ? _a : value.get();
1866
+ const valueTransition = getValueTransition(transition, key) || {};
1867
+ let origin = valueTransition.from !== undefined ? valueTransition.from : value.get();
1853
1868
  const isTargetAnimatable = isAnimatable(key, target);
1854
1869
  if (origin === "none" && isTargetAnimatable && typeof target === "string") {
1855
1870
  /**
@@ -1878,24 +1893,25 @@
1878
1893
  };
1879
1894
  return valueTransition.type === "inertia" ||
1880
1895
  valueTransition.type === "decay"
1881
- ? inertia(Object.assign(Object.assign({}, options), valueTransition))
1882
- : animate$1(Object.assign(Object.assign({}, getPopmotionAnimationOptions(valueTransition, options, key)), { onUpdate: (v) => {
1883
- var _a;
1896
+ ? inertia({ ...options, ...valueTransition })
1897
+ : animate$1({
1898
+ ...getPopmotionAnimationOptions(valueTransition, options, key),
1899
+ onUpdate: (v) => {
1884
1900
  options.onUpdate(v);
1885
- (_a = valueTransition.onUpdate) === null || _a === void 0 ? void 0 : _a.call(valueTransition, v);
1886
- }, onComplete: () => {
1887
- var _a;
1901
+ valueTransition.onUpdate && valueTransition.onUpdate(v);
1902
+ },
1903
+ onComplete: () => {
1888
1904
  options.onComplete();
1889
- (_a = valueTransition.onComplete) === null || _a === void 0 ? void 0 : _a.call(valueTransition);
1890
- } }));
1905
+ valueTransition.onComplete && valueTransition.onComplete();
1906
+ },
1907
+ });
1891
1908
  }
1892
1909
  function set() {
1893
- var _a, _b;
1894
1910
  const finalTarget = resolveFinalValueInKeyframes(target);
1895
1911
  value.set(finalTarget);
1896
1912
  onComplete();
1897
- (_a = valueTransition === null || valueTransition === void 0 ? void 0 : valueTransition.onUpdate) === null || _a === void 0 ? void 0 : _a.call(valueTransition, finalTarget);
1898
- (_b = valueTransition === null || valueTransition === void 0 ? void 0 : valueTransition.onComplete) === null || _b === void 0 ? void 0 : _b.call(valueTransition);
1913
+ valueTransition.onUpdate && valueTransition.onUpdate(finalTarget);
1914
+ valueTransition.onComplete && valueTransition.onComplete();
1899
1915
  return { stop: () => { } };
1900
1916
  }
1901
1917
  return !isOriginAnimatable ||
@@ -1940,7 +1956,7 @@
1940
1956
  }
1941
1957
  return () => {
1942
1958
  clearTimeout(delayTimer);
1943
- controls === null || controls === void 0 ? void 0 : controls.stop();
1959
+ controls && controls.stop();
1944
1960
  };
1945
1961
  });
1946
1962
  }
@@ -2473,42 +2489,6 @@
2473
2489
  return [callback("x"), callback("y")];
2474
2490
  }
2475
2491
 
2476
- /**
2477
- * A list of all transformable axes. We'll use this list to generated a version
2478
- * of each axes for each transform.
2479
- */
2480
- const transformAxes = ["", "X", "Y", "Z"];
2481
- /**
2482
- * An ordered array of each transformable value. By default, transform values
2483
- * will be sorted to this order.
2484
- */
2485
- const order = ["translate", "scale", "rotate", "skew"];
2486
- /**
2487
- * Generate a list of every possible transform key.
2488
- */
2489
- const transformProps = ["transformPerspective", "x", "y", "z"];
2490
- order.forEach((operationKey) => transformAxes.forEach((axesKey) => transformProps.push(operationKey + axesKey)));
2491
- /**
2492
- * A function to use with Array.sort to sort transform keys by their default order.
2493
- */
2494
- function sortTransformProps(a, b) {
2495
- return transformProps.indexOf(a) - transformProps.indexOf(b);
2496
- }
2497
- /**
2498
- * A quick lookup for transform props.
2499
- */
2500
- const transformPropSet = new Set(transformProps);
2501
- function isTransformProp(key) {
2502
- return transformPropSet.has(key);
2503
- }
2504
- /**
2505
- * A quick lookup for transform origin props
2506
- */
2507
- const transformOriginProps = new Set(["originX", "originY", "originZ"]);
2508
- function isTransformOriginProp(key) {
2509
- return transformOriginProps.has(key);
2510
- }
2511
-
2512
2492
  const compareByDepth = (a, b) => a.depth - b.depth;
2513
2493
 
2514
2494
  class FlatTree {
@@ -2561,6 +2541,7 @@
2561
2541
  hasEverUpdated: false,
2562
2542
  };
2563
2543
 
2544
+ const transformAxes = ["", "X", "Y", "Z"];
2564
2545
  /**
2565
2546
  * We use 1000 as the animation target as 0-1000 maps better to pixels than 0-1
2566
2547
  * which has a noticeable difference in spring animations
@@ -2752,7 +2733,11 @@
2752
2733
  this.resumingFrom.resumingFrom = undefined;
2753
2734
  }
2754
2735
  this.setAnimationOrigin(delta, hasOnlyRelativeTargetChanged);
2755
- const animationOptions = Object.assign(Object.assign({}, getValueTransition(layoutTransition, "layout")), { onPlay: onLayoutAnimationStart, onComplete: onLayoutAnimationComplete });
2736
+ const animationOptions = {
2737
+ ...getValueTransition(layoutTransition, "layout"),
2738
+ onPlay: onLayoutAnimationStart,
2739
+ onComplete: onLayoutAnimationComplete,
2740
+ };
2756
2741
  if (visualElement.shouldReduceMotion) {
2757
2742
  animationOptions.delay = 0;
2758
2743
  animationOptions.type = false;
@@ -3075,8 +3060,11 @@
3075
3060
  this.root.scheduleUpdateProjection();
3076
3061
  }
3077
3062
  setOptions(options) {
3078
- var _a;
3079
- this.options = Object.assign(Object.assign(Object.assign({}, this.options), options), { crossfade: (_a = options.crossfade) !== null && _a !== void 0 ? _a : true });
3063
+ this.options = {
3064
+ ...this.options,
3065
+ ...options,
3066
+ crossfade: options.crossfade !== undefined ? options.crossfade : true,
3067
+ };
3080
3068
  }
3081
3069
  clearMeasurements() {
3082
3070
  this.scroll = undefined;
@@ -3258,7 +3246,7 @@
3258
3246
  var _a;
3259
3247
  const snapshot = this.snapshot;
3260
3248
  const snapshotLatestValues = (snapshot === null || snapshot === void 0 ? void 0 : snapshot.latestValues) || {};
3261
- const mixedValues = Object.assign({}, this.latestValues);
3249
+ const mixedValues = { ...this.latestValues };
3262
3250
  const targetDelta = createDelta();
3263
3251
  this.relativeTarget = this.relativeTargetOrigin = undefined;
3264
3252
  this.attemptToResolveRelativeTarget = !hasOnlyRelativeTargetChanged;
@@ -3311,15 +3299,19 @@
3311
3299
  */
3312
3300
  this.pendingAnimation = sync.update(() => {
3313
3301
  globalProjectionState.hasAnimatedSinceResize = true;
3314
- this.currentAnimation = animate(0, animationTarget, Object.assign(Object.assign({}, options), { onUpdate: (latest) => {
3302
+ this.currentAnimation = animate(0, animationTarget, {
3303
+ ...options,
3304
+ onUpdate: (latest) => {
3315
3305
  var _a;
3316
3306
  this.mixTargetDelta(latest);
3317
3307
  (_a = options.onUpdate) === null || _a === void 0 ? void 0 : _a.call(options, latest);
3318
- }, onComplete: () => {
3308
+ },
3309
+ onComplete: () => {
3319
3310
  var _a;
3320
3311
  (_a = options.onComplete) === null || _a === void 0 ? void 0 : _a.call(options);
3321
3312
  this.completeAnimation();
3322
- } }));
3313
+ },
3314
+ });
3323
3315
  if (this.resumingFrom) {
3324
3316
  this.resumingFrom.currentAnimation = this.currentAnimation;
3325
3317
  }
@@ -3454,7 +3446,7 @@
3454
3446
  visualElement.scheduleRender();
3455
3447
  }
3456
3448
  getProjectionStyles(styleProp = {}) {
3457
- var _a, _b, _c, _d, _e, _f;
3449
+ var _a, _b, _c;
3458
3450
  // TODO: Return lifecycle-persistent object
3459
3451
  const styles = {};
3460
3452
  if (!this.instance || this.isSVG)
@@ -3480,7 +3472,10 @@
3480
3472
  if (!this.projectionDelta || !this.layout || !lead.target) {
3481
3473
  const emptyStyles = {};
3482
3474
  if (this.options.layoutId) {
3483
- emptyStyles.opacity = (_b = this.latestValues.opacity) !== null && _b !== void 0 ? _b : 1;
3475
+ emptyStyles.opacity =
3476
+ this.latestValues.opacity !== undefined
3477
+ ? this.latestValues.opacity
3478
+ : 1;
3484
3479
  emptyStyles.pointerEvents =
3485
3480
  resolveMotionValue(styleProp.pointerEvents) || "";
3486
3481
  }
@@ -3507,7 +3502,7 @@
3507
3502
  */
3508
3503
  styles.opacity =
3509
3504
  lead === this
3510
- ? (_d = (_c = valuesToRender.opacity) !== null && _c !== void 0 ? _c : this.latestValues.opacity) !== null && _d !== void 0 ? _d : 1
3505
+ ? (_c = (_b = valuesToRender.opacity) !== null && _b !== void 0 ? _b : this.latestValues.opacity) !== null && _c !== void 0 ? _c : 1
3511
3506
  : this.preserveOpacity
3512
3507
  ? this.latestValues.opacity
3513
3508
  : valuesToRender.opacityExit;
@@ -3519,8 +3514,12 @@
3519
3514
  */
3520
3515
  styles.opacity =
3521
3516
  lead === this
3522
- ? (_e = valuesToRender.opacity) !== null && _e !== void 0 ? _e : ""
3523
- : (_f = valuesToRender.opacityExit) !== null && _f !== void 0 ? _f : 0;
3517
+ ? valuesToRender.opacity !== undefined
3518
+ ? valuesToRender.opacity
3519
+ : ""
3520
+ : valuesToRender.opacityExit !== undefined
3521
+ ? valuesToRender.opacityExit
3522
+ : 0;
3524
3523
  }
3525
3524
  /**
3526
3525
  * Apply scale correction
@@ -3568,8 +3567,8 @@
3568
3567
  node.updateLayout();
3569
3568
  }
3570
3569
  function notifyLayoutUpdate(node) {
3571
- var _a, _b, _c, _d;
3572
- const snapshot = (_b = (_a = node.resumeFrom) === null || _a === void 0 ? void 0 : _a.snapshot) !== null && _b !== void 0 ? _b : node.snapshot;
3570
+ var _a, _b, _c;
3571
+ const snapshot = ((_a = node.resumeFrom) === null || _a === void 0 ? void 0 : _a.snapshot) || node.snapshot;
3573
3572
  if (node.isLead() &&
3574
3573
  node.layout &&
3575
3574
  snapshot &&
@@ -3636,7 +3635,7 @@
3636
3635
  });
3637
3636
  }
3638
3637
  else if (node.isLead()) {
3639
- (_d = (_c = node.options).onExitComplete) === null || _d === void 0 ? void 0 : _d.call(_c);
3638
+ (_c = (_b = node.options).onExitComplete) === null || _c === void 0 ? void 0 : _c.call(_b);
3640
3639
  }
3641
3640
  /**
3642
3641
  * Clearing transition
@@ -3753,7 +3752,7 @@
3753
3752
  return rootProjectionNode.current;
3754
3753
  },
3755
3754
  resetTransform: (instance, value) => {
3756
- instance.style.transform = value !== null && value !== void 0 ? value : "none";
3755
+ instance.style.transform = value !== undefined ? value : "none";
3757
3756
  },
3758
3757
  checkIsScrollRoot: (instance) => Boolean(window.getComputedStyle(instance).position === "fixed"),
3759
3758
  });
@@ -3779,12 +3778,42 @@
3779
3778
  };
3780
3779
  }
3781
3780
 
3781
+ /**
3782
+ * Generate a list of every possible transform key.
3783
+ */
3784
+ const transformPropOrder = [
3785
+ "transformPerspective",
3786
+ "x",
3787
+ "y",
3788
+ "z",
3789
+ "translateX",
3790
+ "translateY",
3791
+ "translateZ",
3792
+ "scale",
3793
+ "scaleX",
3794
+ "scaleY",
3795
+ "rotate",
3796
+ "rotateX",
3797
+ "rotateY",
3798
+ "skew",
3799
+ "skewX",
3800
+ "skewY",
3801
+ ];
3802
+ /**
3803
+ * A quick lookup for transform props.
3804
+ */
3805
+ const transformProps = new Set(transformPropOrder);
3806
+
3782
3807
  const translateAlias = {
3783
3808
  x: "translateX",
3784
3809
  y: "translateY",
3785
3810
  z: "translateZ",
3786
3811
  transformPerspective: "perspective",
3787
3812
  };
3813
+ /**
3814
+ * A function to use with Array.sort to sort transform keys by their default order.
3815
+ */
3816
+ const sortTransformProps = (a, b) => transformPropOrder.indexOf(a) - transformPropOrder.indexOf(b);
3788
3817
  /**
3789
3818
  * Build a CSS transform style from individual x/y/scale etc properties.
3790
3819
  *
@@ -3796,18 +3825,11 @@
3796
3825
  let transformString = "";
3797
3826
  // Transform keys into their default order - this will determine the output order.
3798
3827
  transformKeys.sort(sortTransformProps);
3799
- // Track whether the defined transform has a defined z so we don't add a
3800
- // second to enable hardware acceleration
3801
- let transformHasZ = false;
3802
3828
  // Loop over each transform and build them into transformString
3803
- const numTransformKeys = transformKeys.length;
3804
- for (let i = 0; i < numTransformKeys; i++) {
3805
- const key = transformKeys[i];
3829
+ for (const key of transformKeys) {
3806
3830
  transformString += `${translateAlias[key] || key}(${transform[key]}) `;
3807
- if (key === "z")
3808
- transformHasZ = true;
3809
3831
  }
3810
- if (!transformHasZ && enableHardwareAcceleration) {
3832
+ if (enableHardwareAcceleration && !transform.z) {
3811
3833
  transformString += "translateZ(0)";
3812
3834
  }
3813
3835
  transformString = transformString.trim();
@@ -3821,13 +3843,6 @@
3821
3843
  }
3822
3844
  return transformString;
3823
3845
  }
3824
- /**
3825
- * Build a transformOrigin style. Uses the same defaults as the browser for
3826
- * undefined origins.
3827
- */
3828
- function buildTransformOrigin({ originX = "50%", originY = "50%", originZ = 0, }) {
3829
- return `${originX} ${originY} ${originZ}`;
3830
- }
3831
3846
 
3832
3847
  function pixelsToPercent(pixels, axis) {
3833
3848
  if (axis.max === axis.min)
@@ -3912,16 +3927,14 @@
3912
3927
  *
3913
3928
  * @internal
3914
3929
  */
3915
- function resolveCSSVariables(visualElement, _a, transitionEnd) {
3916
- var _b;
3917
- var target = __rest(_a, []);
3930
+ function resolveCSSVariables(visualElement, { ...target }, transitionEnd) {
3918
3931
  const element = visualElement.getInstance();
3919
3932
  if (!(element instanceof Element))
3920
3933
  return { target, transitionEnd };
3921
3934
  // If `transitionEnd` isn't `undefined`, clone it. We could clone `target` and `transitionEnd`
3922
3935
  // only if they change but I think this reads clearer and this isn't a performance-critical path.
3923
3936
  if (transitionEnd) {
3924
- transitionEnd = Object.assign({}, transitionEnd);
3937
+ transitionEnd = { ...transitionEnd };
3925
3938
  }
3926
3939
  // Go through existing `MotionValue`s and ensure any existing CSS variables are resolved
3927
3940
  visualElement.forEachValue((value) => {
@@ -3946,8 +3959,9 @@
3946
3959
  // If the user hasn't already set this key on `transitionEnd`, set it to the unresolved
3947
3960
  // CSS variable. This will ensure that after the animation the component will reflect
3948
3961
  // changes in the value of the CSS variable.
3949
- if (transitionEnd)
3950
- (_b = transitionEnd[key]) !== null && _b !== void 0 ? _b : (transitionEnd[key] = current);
3962
+ if (transitionEnd && transitionEnd[key] === undefined) {
3963
+ transitionEnd[key] = current;
3964
+ }
3951
3965
  }
3952
3966
  return { target, transitionEnd };
3953
3967
  }
@@ -4004,10 +4018,35 @@
4004
4018
  },
4005
4019
  };
4006
4020
 
4021
+ const isBrowser = typeof document !== "undefined";
4022
+
4023
+ // Does this device prefer reduced motion? Returns `null` server-side.
4024
+ const prefersReducedMotion = { current: null };
4025
+ const hasReducedMotionListener = { current: false };
4026
+
4027
+ function initPrefersReducedMotion() {
4028
+ hasReducedMotionListener.current = true;
4029
+ if (!isBrowser)
4030
+ return;
4031
+ if (window.matchMedia) {
4032
+ const motionMediaQuery = window.matchMedia("(prefers-reduced-motion)");
4033
+ const setReducedMotionPreferences = () => (prefersReducedMotion.current = motionMediaQuery.matches);
4034
+ motionMediaQuery.addListener(setReducedMotionPreferences);
4035
+ setReducedMotionPreferences();
4036
+ }
4037
+ else {
4038
+ prefersReducedMotion.current = false;
4039
+ }
4040
+ }
4041
+
4007
4042
  function isWillChangeMotionValue(value) {
4008
4043
  return Boolean(isMotionValue(value) && value.add);
4009
4044
  }
4010
4045
 
4046
+ function isAnimationControls(v) {
4047
+ return typeof v === "object" && typeof v.start === "function";
4048
+ }
4049
+
4011
4050
  /**
4012
4051
  * Check if value is a numerical string, ie a string that is purely a number eg "100" or "-100.1"
4013
4052
  */
@@ -4049,36 +4088,8 @@
4049
4088
  */
4050
4089
  const findValueType = (v) => valueTypes.find(testValueType(v));
4051
4090
 
4052
- /**
4053
- * Decides if the supplied variable is an array of variant labels
4054
- */
4055
- function isVariantLabels(v) {
4056
- return Array.isArray(v);
4057
- }
4058
- /**
4059
- * Decides if the supplied variable is variant label
4060
- */
4061
- function isVariantLabel(v) {
4062
- return typeof v === "string" || isVariantLabels(v);
4063
- }
4064
- function checkIfControllingVariants(props) {
4065
- var _a;
4066
- return (typeof ((_a = props.animate) === null || _a === void 0 ? void 0 : _a.start) === "function" ||
4067
- isVariantLabel(props.initial) ||
4068
- isVariantLabel(props.animate) ||
4069
- isVariantLabel(props.whileHover) ||
4070
- isVariantLabel(props.whileDrag) ||
4071
- isVariantLabel(props.whileTap) ||
4072
- isVariantLabel(props.whileFocus) ||
4073
- isVariantLabel(props.exit));
4074
- }
4075
- function checkIfVariantNode(props) {
4076
- return Boolean(checkIfControllingVariants(props) || props.variants);
4077
- }
4078
-
4079
4091
  function checkTargetForNewValues(visualElement, target, origin) {
4080
- var _a, _b, _c;
4081
- var _d;
4092
+ var _a, _b;
4082
4093
  const newValueKeys = Object.keys(target).filter((key) => !visualElement.hasValue(key));
4083
4094
  const numNewValues = newValueKeys.length;
4084
4095
  if (!numNewValues)
@@ -4117,7 +4128,9 @@
4117
4128
  value = getAnimatableNone(key, targetValue);
4118
4129
  }
4119
4130
  visualElement.addValue(key, motionValue(value));
4120
- (_c = (_d = origin)[key]) !== null && _c !== void 0 ? _c : (_d[key] = value);
4131
+ if (origin[key] === undefined) {
4132
+ origin[key] = value;
4133
+ }
4121
4134
  visualElement.setBaseTarget(key, value);
4122
4135
  }
4123
4136
  }
@@ -4128,15 +4141,25 @@
4128
4141
  return valueTransition.from;
4129
4142
  }
4130
4143
  function getOrigin(target, transition, visualElement) {
4131
- var _a, _b;
4144
+ var _a;
4132
4145
  const origin = {};
4133
4146
  for (const key in target) {
4147
+ const transitionOrigin = getOriginFromTransition(key, transition);
4134
4148
  origin[key] =
4135
- (_a = getOriginFromTransition(key, transition)) !== null && _a !== void 0 ? _a : (_b = visualElement.getValue(key)) === null || _b === void 0 ? void 0 : _b.get();
4149
+ transitionOrigin !== undefined
4150
+ ? transitionOrigin
4151
+ : (_a = visualElement.getValue(key)) === null || _a === void 0 ? void 0 : _a.get();
4136
4152
  }
4137
4153
  return origin;
4138
4154
  }
4139
4155
 
4156
+ /**
4157
+ * Decides if the supplied variable is variant label
4158
+ */
4159
+ function isVariantLabel(v) {
4160
+ return typeof v === "string" || Array.isArray(v);
4161
+ }
4162
+
4140
4163
  var AnimationType;
4141
4164
  (function (AnimationType) {
4142
4165
  AnimationType["Animate"] = "animate";
@@ -4209,7 +4232,6 @@
4209
4232
  }
4210
4233
 
4211
4234
  function updateMotionValuesFromProps(element, next, prev) {
4212
- var _a;
4213
4235
  const { willChange } = next;
4214
4236
  for (const key in next) {
4215
4237
  const nextValue = next[key];
@@ -4228,7 +4250,7 @@
4228
4250
  * and warn against mismatches.
4229
4251
  */
4230
4252
  {
4231
- warnOnce(nextValue.version === "7.2.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.2.0 may not work as expected.`);
4253
+ warnOnce(nextValue.version === "7.2.1", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.2.1 may not work as expected.`);
4232
4254
  }
4233
4255
  }
4234
4256
  else if (isMotionValue(prevValue)) {
@@ -4253,7 +4275,8 @@
4253
4275
  !existingValue.hasAnimated && existingValue.set(nextValue);
4254
4276
  }
4255
4277
  else {
4256
- element.addValue(key, motionValue((_a = element.getStaticValue(key)) !== null && _a !== void 0 ? _a : nextValue));
4278
+ const latestValue = element.getStaticValue(key);
4279
+ element.addValue(key, motionValue(latestValue !== undefined ? latestValue : nextValue));
4257
4280
  }
4258
4281
  }
4259
4282
  }
@@ -4265,7 +4288,73 @@
4265
4288
  return next;
4266
4289
  }
4267
4290
 
4268
- const visualElement = ({ treeType = "", build, getBaseTarget, makeTargetAnimatable, measureViewportBox, render: renderInstance, readValueFromInstance, removeValueFromRenderState, sortNodePosition, scrapeMotionValuesFromProps, }) => ({ parent, props, presenceId, blockInitialAnimation, visualState, shouldReduceMotion, }, options = {}) => {
4291
+ const variantProps$1 = [
4292
+ "initial",
4293
+ "animate",
4294
+ "exit",
4295
+ "whileHover",
4296
+ "whileDrag",
4297
+ "whileTap",
4298
+ "whileFocus",
4299
+ "whileInView",
4300
+ ];
4301
+ function isControllingVariants(props) {
4302
+ return (isAnimationControls(props.animate) ||
4303
+ variantProps$1.some((name) => isVariantLabel(props[name])));
4304
+ }
4305
+ function isVariantNode(props) {
4306
+ return Boolean(isControllingVariants(props) || props.variants);
4307
+ }
4308
+
4309
+ /**
4310
+ * Browser-safe usage of process
4311
+ */
4312
+ const defaultEnvironment = "production";
4313
+ const env = typeof process === "undefined" || process.env === undefined
4314
+ ? defaultEnvironment
4315
+ : "development" ;
4316
+
4317
+ const createDefinition = (propNames) => ({
4318
+ isEnabled: (props) => propNames.some((name) => !!props[name]),
4319
+ });
4320
+ const featureDefinitions = {
4321
+ measureLayout: createDefinition(["layout", "layoutId", "drag"]),
4322
+ animation: createDefinition([
4323
+ "animate",
4324
+ "exit",
4325
+ "variants",
4326
+ "whileHover",
4327
+ "whileTap",
4328
+ "whileFocus",
4329
+ "whileDrag",
4330
+ "whileInView",
4331
+ ]),
4332
+ exit: createDefinition(["exit"]),
4333
+ drag: createDefinition(["drag", "dragControls"]),
4334
+ focus: createDefinition(["whileFocus"]),
4335
+ hover: createDefinition(["whileHover", "onHoverStart", "onHoverEnd"]),
4336
+ tap: createDefinition(["whileTap", "onTap", "onTapStart", "onTapCancel"]),
4337
+ pan: createDefinition([
4338
+ "onPan",
4339
+ "onPanStart",
4340
+ "onPanSessionStart",
4341
+ "onPanEnd",
4342
+ ]),
4343
+ inView: createDefinition([
4344
+ "whileInView",
4345
+ "onViewportEnter",
4346
+ "onViewportLeave",
4347
+ ]),
4348
+ };
4349
+
4350
+ function isRefObject(ref) {
4351
+ return (typeof ref === "object" &&
4352
+ Object.prototype.hasOwnProperty.call(ref, "current"));
4353
+ }
4354
+
4355
+ const featureNames = Object.keys(featureDefinitions);
4356
+ const numFeatures = featureNames.length;
4357
+ const visualElement = ({ treeType = "", build, getBaseTarget, makeTargetAnimatable, measureViewportBox, render: renderInstance, readValueFromInstance, removeValueFromRenderState, sortNodePosition, scrapeMotionValuesFromProps, }) => ({ parent, props, presenceId, blockInitialAnimation, visualState, reducedMotionConfig, }, options = {}) => {
4269
4358
  let isMounted = false;
4270
4359
  const { latestValues, renderState } = visualState;
4271
4360
  /**
@@ -4301,7 +4390,9 @@
4301
4390
  * When values are removed from all animation props we need to search
4302
4391
  * for a fallback value to animate to. These values are tracked in baseTarget.
4303
4392
  */
4304
- const baseTarget = Object.assign({}, latestValues);
4393
+ const baseTarget = {
4394
+ ...latestValues,
4395
+ };
4305
4396
  // Internal methods ========================
4306
4397
  /**
4307
4398
  * On mount, this will be hydrated with a callback to disconnect
@@ -4348,7 +4439,7 @@
4348
4439
  * Doing so will break some tests but this isn't neccessarily a breaking change,
4349
4440
  * more a reflection of the test.
4350
4441
  */
4351
- const _a = scrapeMotionValuesFromProps(props), { willChange } = _a, initialMotionValues = __rest(_a, ["willChange"]);
4442
+ const { willChange, ...initialMotionValues } = scrapeMotionValuesFromProps(props);
4352
4443
  for (const key in initialMotionValues) {
4353
4444
  const value = initialMotionValues[key];
4354
4445
  if (latestValues[key] !== undefined && isMotionValue(value)) {
@@ -4361,36 +4452,39 @@
4361
4452
  /**
4362
4453
  * Determine what role this visual element should take in the variant tree.
4363
4454
  */
4364
- const isControllingVariants = checkIfControllingVariants(props);
4365
- const isVariantNode = checkIfVariantNode(props);
4366
- const element = Object.assign(Object.assign({ treeType,
4455
+ const isControllingVariants$1 = isControllingVariants(props);
4456
+ const isVariantNode$1 = isVariantNode(props);
4457
+ const element = {
4458
+ treeType,
4367
4459
  /**
4368
4460
  * This is a mirror of the internal instance prop, which keeps
4369
4461
  * VisualElement type-compatible with React's RefObject.
4370
4462
  */
4371
- current: null,
4463
+ current: null,
4372
4464
  /**
4373
4465
  * The depth of this visual element within the visual element tree.
4374
4466
  */
4375
- depth: parent ? parent.depth + 1 : 0, parent, children: new Set(),
4467
+ depth: parent ? parent.depth + 1 : 0,
4468
+ parent,
4469
+ children: new Set(),
4376
4470
  /**
4377
4471
  *
4378
4472
  */
4379
4473
  presenceId,
4380
- shouldReduceMotion,
4474
+ shouldReduceMotion: null,
4381
4475
  /**
4382
4476
  * If this component is part of the variant tree, it should track
4383
4477
  * any children that are also part of the tree. This is essentially
4384
4478
  * a shadow tree to simplify logic around how to stagger over children.
4385
4479
  */
4386
- variantChildren: isVariantNode ? new Set() : undefined,
4480
+ variantChildren: isVariantNode$1 ? new Set() : undefined,
4387
4481
  /**
4388
4482
  * Whether this instance is visible. This can be changed imperatively
4389
4483
  * by the projection tree, is analogous to CSS's visibility in that
4390
4484
  * hidden elements should take up layout, and needs enacting by the configured
4391
4485
  * render function.
4392
4486
  */
4393
- isVisible: undefined,
4487
+ isVisible: undefined,
4394
4488
  /**
4395
4489
  * Normally, if a component is controlled by a parent's variants, it can
4396
4490
  * rely on that ancestor to trigger animations further down the tree.
@@ -4399,27 +4493,37 @@
4399
4493
  *
4400
4494
  * TODO: This might be better replaced with a method isParentMounted
4401
4495
  */
4402
- manuallyAnimateOnMount: Boolean(parent === null || parent === void 0 ? void 0 : parent.isMounted()),
4496
+ manuallyAnimateOnMount: Boolean(parent === null || parent === void 0 ? void 0 : parent.isMounted()),
4403
4497
  /**
4404
4498
  * This can be set by AnimatePresence to force components that mount
4405
4499
  * at the same time as it to mount as if they have initial={false} set.
4406
4500
  */
4407
- blockInitialAnimation,
4501
+ blockInitialAnimation,
4408
4502
  /**
4409
4503
  * Determine whether this component has mounted yet. This is mostly used
4410
4504
  * by variant children to determine whether they need to trigger their
4411
4505
  * own animations on mount.
4412
4506
  */
4413
- isMounted: () => Boolean(instance), mount(newInstance) {
4507
+ isMounted: () => Boolean(instance),
4508
+ mount(newInstance) {
4414
4509
  isMounted = true;
4415
4510
  instance = element.current = newInstance;
4416
4511
  if (element.projection) {
4417
4512
  element.projection.mount(newInstance);
4418
4513
  }
4419
- if (isVariantNode && parent && !isControllingVariants) {
4514
+ if (isVariantNode$1 && parent && !isControllingVariants$1) {
4420
4515
  removeFromVariantTree = parent === null || parent === void 0 ? void 0 : parent.addVariantChild(element);
4421
4516
  }
4422
4517
  values.forEach((value, key) => bindToMotionValue(key, value));
4518
+ if (!hasReducedMotionListener.current) {
4519
+ initPrefersReducedMotion();
4520
+ }
4521
+ element.shouldReduceMotion =
4522
+ reducedMotionConfig === "never"
4523
+ ? false
4524
+ : reducedMotionConfig === "always"
4525
+ ? true
4526
+ : prefersReducedMotion.current;
4423
4527
  parent === null || parent === void 0 ? void 0 : parent.children.add(element);
4424
4528
  element.setProps(props);
4425
4529
  },
@@ -4438,6 +4542,55 @@
4438
4542
  instance = undefined;
4439
4543
  isMounted = false;
4440
4544
  },
4545
+ loadFeatures(renderedProps, isStrict, preloadedFeatures, projectionId, ProjectionNodeConstructor, initialLayoutGroupConfig) {
4546
+ const features = [];
4547
+ /**
4548
+ * If we're in development mode, check to make sure we're not rendering a motion component
4549
+ * as a child of LazyMotion, as this will break the file-size benefits of using it.
4550
+ */
4551
+ if (env !== "production" && preloadedFeatures && isStrict) {
4552
+ invariant(false, "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.");
4553
+ }
4554
+ for (let i = 0; i < numFeatures; i++) {
4555
+ const name = featureNames[i];
4556
+ const { isEnabled, Component } = featureDefinitions[name];
4557
+ /**
4558
+ * It might be possible in the future to use this moment to
4559
+ * dynamically request functionality. In initial tests this
4560
+ * was producing a lot of duplication amongst bundles.
4561
+ */
4562
+ if (isEnabled(props) && Component) {
4563
+ features.push(react.createElement(Component, {
4564
+ key: name,
4565
+ ...renderedProps,
4566
+ visualElement: element,
4567
+ }));
4568
+ }
4569
+ }
4570
+ if (!element.projection && ProjectionNodeConstructor) {
4571
+ element.projection = new ProjectionNodeConstructor(projectionId, element.getLatestValues(), parent && parent.projection);
4572
+ const { layoutId, layout, drag, dragConstraints, layoutScroll, } = renderedProps;
4573
+ element.projection.setOptions({
4574
+ layoutId,
4575
+ layout,
4576
+ alwaysMeasureLayout: Boolean(drag) ||
4577
+ (dragConstraints && isRefObject(dragConstraints)),
4578
+ visualElement: element,
4579
+ scheduleRender: () => element.scheduleRender(),
4580
+ /**
4581
+ * TODO: Update options in an effect. This could be tricky as it'll be too late
4582
+ * to update by the time layout animations run.
4583
+ * We also need to fix this safeToRemove by linking it up to the one returned by usePresence,
4584
+ * ensuring it gets called if there's no potential layout animations.
4585
+ *
4586
+ */
4587
+ animationType: typeof layout === "string" ? layout : "both",
4588
+ initialPromotionConfig: initialLayoutGroupConfig,
4589
+ layoutScroll,
4590
+ });
4591
+ }
4592
+ return features;
4593
+ },
4441
4594
  /**
4442
4595
  * Add a child visual element to our set of children.
4443
4596
  */
@@ -4456,30 +4609,31 @@
4456
4609
  if (!sortNodePosition || treeType !== other.treeType)
4457
4610
  return 0;
4458
4611
  return sortNodePosition(element.getInstance(), other.getInstance());
4459
- },
4612
+ },
4460
4613
  /**
4461
4614
  * Returns the closest variant node in the tree starting from
4462
4615
  * this visual element.
4463
4616
  */
4464
- getClosestVariantNode: () => isVariantNode ? element : parent === null || parent === void 0 ? void 0 : parent.getClosestVariantNode(),
4617
+ getClosestVariantNode: () => isVariantNode$1 ? element : parent === null || parent === void 0 ? void 0 : parent.getClosestVariantNode(),
4465
4618
  /**
4466
4619
  * Expose the latest layoutId prop.
4467
4620
  */
4468
- getLayoutId: () => props.layoutId,
4621
+ getLayoutId: () => props.layoutId,
4469
4622
  /**
4470
4623
  * Returns the current instance.
4471
4624
  */
4472
- getInstance: () => instance,
4625
+ getInstance: () => instance,
4473
4626
  /**
4474
4627
  * Get/set the latest static values.
4475
4628
  */
4476
- getStaticValue: (key) => latestValues[key], setStaticValue: (key, value) => (latestValues[key] = value),
4629
+ getStaticValue: (key) => latestValues[key],
4630
+ setStaticValue: (key, value) => (latestValues[key] = value),
4477
4631
  /**
4478
4632
  * Returns the latest motion value state. Currently only used to take
4479
4633
  * a snapshot of the visual element - perhaps this can return the whole
4480
4634
  * visual state
4481
4635
  */
4482
- getLatestValues: () => latestValues,
4636
+ getLatestValues: () => latestValues,
4483
4637
  /**
4484
4638
  * Set the visiblity of the visual element. If it's changed, schedule
4485
4639
  * a render to reflect these changes.
@@ -4530,11 +4684,11 @@
4530
4684
  valueSubscriptions.delete(key);
4531
4685
  delete latestValues[key];
4532
4686
  removeValueFromRenderState(key, renderState);
4533
- },
4687
+ },
4534
4688
  /**
4535
4689
  * Check whether we have a motion value for this key
4536
4690
  */
4537
- hasValue: (key) => values.has(key),
4691
+ hasValue: (key) => values.has(key),
4538
4692
  /**
4539
4693
  * Get a motion value for this key. If called with a default
4540
4694
  * value, we'll create one if none exists.
@@ -4546,20 +4700,19 @@
4546
4700
  element.addValue(key, value);
4547
4701
  }
4548
4702
  return value;
4549
- },
4703
+ },
4550
4704
  /**
4551
4705
  * Iterate over our motion values.
4552
4706
  */
4553
- forEachValue: (callback) => values.forEach(callback),
4707
+ forEachValue: (callback) => values.forEach(callback),
4554
4708
  /**
4555
4709
  * If we're trying to animate to a previously unencountered value,
4556
4710
  * we need to check for it in our state and as a last resort read it
4557
4711
  * directly from the instance (which might have performance implications).
4558
4712
  */
4559
- readValue: (key) => {
4560
- var _a;
4561
- return (_a = latestValues[key]) !== null && _a !== void 0 ? _a : readValueFromInstance(instance, key, options);
4562
- },
4713
+ readValue: (key) => latestValues[key] !== undefined
4714
+ ? latestValues[key]
4715
+ : readValueFromInstance(instance, key, options),
4563
4716
  /**
4564
4717
  * Set the base target to later animate back to. This is currently
4565
4718
  * only hydrated on creation and when we first read a value.
@@ -4578,7 +4731,9 @@
4578
4731
  return target;
4579
4732
  }
4580
4733
  return baseTarget[key];
4581
- } }, lifecycles), {
4734
+ },
4735
+ // Lifecyles ========================
4736
+ ...lifecycles,
4582
4737
  /**
4583
4738
  * Build the renderer state based on the latest visual state.
4584
4739
  */
@@ -4591,14 +4746,14 @@
4591
4746
  */
4592
4747
  scheduleRender() {
4593
4748
  sync.render(render, false, true);
4594
- },
4749
+ },
4595
4750
  /**
4596
4751
  * Synchronously fire render. It's prefered that we batch renders but
4597
4752
  * in many circumstances, like layout measurement, we need to run this
4598
4753
  * synchronously. However in those instances other measures should be taken
4599
4754
  * to batch reads/writes.
4600
4755
  */
4601
- syncRender: render,
4756
+ syncRender: render,
4602
4757
  /**
4603
4758
  * Update the provided props. Ensure any newly-added motion values are
4604
4759
  * added to our map, old ones removed, and listeners updated.
@@ -4610,25 +4765,27 @@
4610
4765
  props = newProps;
4611
4766
  lifecycles.updatePropListeners(newProps);
4612
4767
  prevMotionValues = updateMotionValuesFromProps(element, scrapeMotionValuesFromProps(props), prevMotionValues);
4613
- }, getProps: () => props,
4768
+ },
4769
+ getProps: () => props,
4614
4770
  // Variants ==============================
4615
4771
  /**
4616
4772
  * Returns the variant definition with a given name.
4617
4773
  */
4618
- getVariant: (name) => { var _a; return (_a = props.variants) === null || _a === void 0 ? void 0 : _a[name]; },
4774
+ getVariant: (name) => { var _a; return (_a = props.variants) === null || _a === void 0 ? void 0 : _a[name]; },
4619
4775
  /**
4620
4776
  * Returns the defined default transition on this component.
4621
4777
  */
4622
- getDefaultTransition: () => props.transition, getTransformPagePoint: () => {
4778
+ getDefaultTransition: () => props.transition,
4779
+ getTransformPagePoint: () => {
4623
4780
  return props.transformPagePoint;
4624
- },
4781
+ },
4625
4782
  /**
4626
4783
  * Used by child variant nodes to get the closest ancestor variant props.
4627
4784
  */
4628
4785
  getVariantContext(startAtParent = false) {
4629
4786
  if (startAtParent)
4630
4787
  return parent === null || parent === void 0 ? void 0 : parent.getVariantContext();
4631
- if (!isControllingVariants) {
4788
+ if (!isControllingVariants$1) {
4632
4789
  const context = (parent === null || parent === void 0 ? void 0 : parent.getVariantContext()) || {};
4633
4790
  if (props.initial !== undefined) {
4634
4791
  context.initial = props.initial;
@@ -4644,7 +4801,8 @@
4644
4801
  }
4645
4802
  }
4646
4803
  return context;
4647
- } });
4804
+ },
4805
+ };
4648
4806
  return element;
4649
4807
  };
4650
4808
  const variantProps = ["initial", ...variantPriorityOrder];
@@ -4667,11 +4825,7 @@
4667
4825
  };
4668
4826
 
4669
4827
  function buildHTMLStyles(state, latestValues, options, transformTemplate) {
4670
- var _a;
4671
4828
  const { style, vars, transform, transformKeys, transformOrigin } = state;
4672
- // Empty the transformKeys array. As we're throwing out refs to its items
4673
- // this might not be as cheap as suspected. Maybe using the array as a buffer
4674
- // with a manual incrementation would be better.
4675
4829
  transformKeys.length = 0;
4676
4830
  // Track whether we encounter any transform or transformOrigin values.
4677
4831
  let hasTransform = false;
@@ -4696,7 +4850,7 @@
4696
4850
  // Convert the value to its default value type, ie 0 -> "0px"
4697
4851
  const valueType = numberValueTypes[key];
4698
4852
  const valueAsType = getValueAsType(value, valueType);
4699
- if (isTransformProp(key)) {
4853
+ if (transformProps.has(key)) {
4700
4854
  // If this is a transform, flag to enable further transform processing
4701
4855
  hasTransform = true;
4702
4856
  transform[key] = valueAsType;
@@ -4705,34 +4859,38 @@
4705
4859
  if (!transformIsNone)
4706
4860
  continue;
4707
4861
  // Otherwise check to see if this is a default transform
4708
- if (value !== ((_a = valueType.default) !== null && _a !== void 0 ? _a : 0))
4862
+ if (value !== (valueType.default || 0))
4709
4863
  transformIsNone = false;
4710
4864
  }
4711
- else if (isTransformOriginProp(key)) {
4712
- transformOrigin[key] = valueAsType;
4865
+ else if (key.startsWith("origin")) {
4713
4866
  // If this is a transform origin, flag and enable further transform-origin processing
4714
4867
  hasTransformOrigin = true;
4868
+ transformOrigin[key] = valueAsType;
4715
4869
  }
4716
4870
  else {
4717
4871
  style[key] = valueAsType;
4718
4872
  }
4719
4873
  }
4720
- if (hasTransform) {
4874
+ if (hasTransform || transformTemplate) {
4721
4875
  style.transform = buildTransform(state, options, transformIsNone, transformTemplate);
4722
4876
  }
4723
- else if (transformTemplate) {
4724
- style.transform = transformTemplate({}, "");
4725
- }
4726
4877
  else if (!latestValues.transform && style.transform) {
4878
+ /**
4879
+ * If we have previously created a transform but currently don't have any,
4880
+ * reset transform style to none.
4881
+ */
4727
4882
  style.transform = "none";
4728
4883
  }
4884
+ /**
4885
+ * Build a transformOrigin style. Uses the same defaults as the browser for
4886
+ * undefined origins.
4887
+ */
4729
4888
  if (hasTransformOrigin) {
4730
- style.transformOrigin = buildTransformOrigin(transformOrigin);
4889
+ const { originX = "50%", originY = "50%", originZ = 0, } = transformOrigin;
4890
+ style.transformOrigin = `${originX} ${originY} ${originZ}`;
4731
4891
  }
4732
4892
  }
4733
4893
 
4734
- const isBrowser = typeof document !== "undefined";
4735
-
4736
4894
  const positionalKeys = new Set([
4737
4895
  "width",
4738
4896
  "height",
@@ -4782,7 +4940,7 @@
4782
4940
  }
4783
4941
  };
4784
4942
  const transformKeys = new Set(["x", "y", "z"]);
4785
- const nonTranslationalTransformKeys = transformProps.filter((key) => !transformKeys.has(key));
4943
+ const nonTranslationalTransformKeys = transformPropOrder.filter((key) => !transformKeys.has(key));
4786
4944
  function removeNonTranslationalTransform(visualElement) {
4787
4945
  const removedTransforms = [];
4788
4946
  nonTranslationalTransformKeys.forEach((key) => {
@@ -4839,8 +4997,8 @@
4839
4997
  return target;
4840
4998
  };
4841
4999
  const checkAndConvertChangedValueTypes = (visualElement, target, origin = {}, transitionEnd = {}) => {
4842
- target = Object.assign({}, target);
4843
- transitionEnd = Object.assign({}, transitionEnd);
5000
+ target = { ...target };
5001
+ transitionEnd = { ...transitionEnd };
4844
5002
  const targetPositionalKeys = Object.keys(target).filter(isPositionalKey);
4845
5003
  // We want to remove any transform values that could affect the element's bounding box before
4846
5004
  // it's measured. We'll reapply these later.
@@ -4970,8 +5128,8 @@
4970
5128
  };
4971
5129
 
4972
5130
  function isForcedMotionValue(key, { layout, layoutId }) {
4973
- return (isTransformProp(key) ||
4974
- isTransformOriginProp(key) ||
5131
+ return (transformProps.has(key) ||
5132
+ key.startsWith("origin") ||
4975
5133
  ((layout || layoutId !== undefined) &&
4976
5134
  (!!scaleCorrectors[key] || key === "opacity")));
4977
5135
  }
@@ -5034,7 +5192,7 @@
5034
5192
  const htmlConfig = {
5035
5193
  treeType: "dom",
5036
5194
  readValueFromInstance(domElement, key) {
5037
- if (isTransformProp(key)) {
5195
+ if (transformProps.has(key)) {
5038
5196
  const defaultType = getDefaultValueType(key);
5039
5197
  return defaultType ? defaultType.default || 0 : 0;
5040
5198
  }
@@ -5087,10 +5245,7 @@
5087
5245
  * Ensure that HTML and Framer-specific value types like `px`->`%` and `Color`
5088
5246
  * can be animated by Motion.
5089
5247
  */
5090
- makeTargetAnimatable(element, _a, _b, isMounted) {
5091
- var { transition, transitionEnd } = _a, target = __rest(_a, ["transition", "transitionEnd"]);
5092
- var transformValues = _b.transformValues;
5093
- if (isMounted === void 0) { isMounted = true; }
5248
+ makeTargetAnimatable(element, { transition, transitionEnd, ...target }, { transformValues }, isMounted = true) {
5094
5249
  let origin = getOrigin(target, transition || {}, element);
5095
5250
  /**
5096
5251
  * If Framer has provided a function to convert `Color` etc value types, convert them
@@ -5109,8 +5264,11 @@
5109
5264
  transitionEnd = parsed.transitionEnd;
5110
5265
  target = parsed.target;
5111
5266
  }
5112
- return Object.assign({ transition,
5113
- transitionEnd }, target);
5267
+ return {
5268
+ transition,
5269
+ transitionEnd,
5270
+ ...target,
5271
+ };
5114
5272
  },
5115
5273
  scrapeMotionValuesFromProps,
5116
5274
  build(element, renderState, latestValues, options, props) {