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,16 +1,14 @@
1
- var notify = function (node) {
2
- return !node.isLayoutDirty && node.willUpdate(false);
3
- };
1
+ const notify = (node) => !node.isLayoutDirty && node.willUpdate(false);
4
2
  function nodeGroup() {
5
- var nodes = new Set();
6
- var subscriptions = new WeakMap();
7
- var dirtyAll = function () { return nodes.forEach(notify); };
3
+ const nodes = new Set();
4
+ const subscriptions = new WeakMap();
5
+ const dirtyAll = () => nodes.forEach(notify);
8
6
  return {
9
- add: function (node) {
7
+ add: (node) => {
10
8
  nodes.add(node);
11
9
  subscriptions.set(node, node.addEventListener("willUpdate", dirtyAll));
12
10
  },
13
- remove: function (node) {
11
+ remove: (node) => {
14
12
  var _a;
15
13
  nodes.delete(node);
16
14
  (_a = subscriptions.get(node)) === null || _a === void 0 ? void 0 : _a();
@@ -1,9 +1,9 @@
1
1
  import { useConstant } from '../../utils/use-constant.mjs';
2
2
  import { globalProjectionState } from './state.mjs';
3
3
 
4
- var id = 1;
4
+ let id = 1;
5
5
  function useProjectionId() {
6
- return useConstant(function () {
6
+ return useConstant(() => {
7
7
  if (globalProjectionState.hasEverUpdated) {
8
8
  return id++;
9
9
  }
@@ -3,7 +3,7 @@
3
3
  * persist through server requests. If we need instanced states we
4
4
  * could lazy-init via root.
5
5
  */
6
- var globalProjectionState = {
6
+ const globalProjectionState = {
7
7
  /**
8
8
  * Global flag as to whether the tree has animated since the last time
9
9
  * we resized the window
@@ -1,35 +1,35 @@
1
1
  import { addUniqueItem, removeItem } from '../../utils/array.mjs';
2
2
 
3
- var NodeStack = /** @class */ (function () {
4
- function NodeStack() {
3
+ class NodeStack {
4
+ constructor() {
5
5
  this.members = [];
6
6
  }
7
- NodeStack.prototype.add = function (node) {
7
+ add(node) {
8
8
  addUniqueItem(this.members, node);
9
9
  node.scheduleRender();
10
- };
11
- NodeStack.prototype.remove = function (node) {
10
+ }
11
+ remove(node) {
12
12
  removeItem(this.members, node);
13
13
  if (node === this.prevLead) {
14
14
  this.prevLead = undefined;
15
15
  }
16
16
  if (node === this.lead) {
17
- var prevLead = this.members[this.members.length - 1];
17
+ const prevLead = this.members[this.members.length - 1];
18
18
  if (prevLead) {
19
19
  this.promote(prevLead);
20
20
  }
21
21
  }
22
- };
23
- NodeStack.prototype.relegate = function (node) {
24
- var indexOfNode = this.members.findIndex(function (member) { return node === member; });
22
+ }
23
+ relegate(node) {
24
+ const indexOfNode = this.members.findIndex((member) => node === member);
25
25
  if (indexOfNode === 0)
26
26
  return false;
27
27
  /**
28
28
  * Find the next projection node that is present
29
29
  */
30
- var prevLead;
31
- for (var i = indexOfNode; i >= 0; i--) {
32
- var member = this.members[i];
30
+ let prevLead;
31
+ for (let i = indexOfNode; i >= 0; i--) {
32
+ const member = this.members[i];
33
33
  if (member.isPresent !== false) {
34
34
  prevLead = member;
35
35
  break;
@@ -42,10 +42,10 @@ var NodeStack = /** @class */ (function () {
42
42
  else {
43
43
  return false;
44
44
  }
45
- };
46
- NodeStack.prototype.promote = function (node, preserveFollowOpacity) {
45
+ }
46
+ promote(node, preserveFollowOpacity) {
47
47
  var _a;
48
- var prevLead = this.lead;
48
+ const prevLead = this.lead;
49
49
  if (node === prevLead)
50
50
  return;
51
51
  this.prevLead = prevLead;
@@ -67,7 +67,7 @@ var NodeStack = /** @class */ (function () {
67
67
  if ((_a = node.root) === null || _a === void 0 ? void 0 : _a.isUpdating) {
68
68
  node.isLayoutDirty = true;
69
69
  }
70
- var crossfade = node.options.crossfade;
70
+ const { crossfade } = node.options;
71
71
  if (crossfade === false) {
72
72
  prevLead.hide();
73
73
  }
@@ -84,29 +84,28 @@ var NodeStack = /** @class */ (function () {
84
84
  * - layoutId changes mid animation
85
85
  */
86
86
  }
87
- };
88
- NodeStack.prototype.exitAnimationComplete = function () {
89
- this.members.forEach(function (node) {
87
+ }
88
+ exitAnimationComplete() {
89
+ this.members.forEach((node) => {
90
90
  var _a, _b, _c, _d, _e;
91
91
  (_b = (_a = node.options).onExitComplete) === null || _b === void 0 ? void 0 : _b.call(_a);
92
92
  (_e = (_c = node.resumingFrom) === null || _c === void 0 ? void 0 : (_d = _c.options).onExitComplete) === null || _e === void 0 ? void 0 : _e.call(_d);
93
93
  });
94
- };
95
- NodeStack.prototype.scheduleRender = function () {
96
- this.members.forEach(function (node) {
94
+ }
95
+ scheduleRender() {
96
+ this.members.forEach((node) => {
97
97
  node.instance && node.scheduleRender(false);
98
98
  });
99
- };
99
+ }
100
100
  /**
101
101
  * Clear any leads that have been removed this render to prevent them from being
102
102
  * used in future animations and to prevent memory leaks
103
103
  */
104
- NodeStack.prototype.removeLeadSnapshot = function () {
104
+ removeLeadSnapshot() {
105
105
  if (this.lead && this.lead.snapshot) {
106
106
  this.lead.snapshot = undefined;
107
107
  }
108
- };
109
- return NodeStack;
110
- }());
108
+ }
109
+ }
111
110
 
112
111
  export { NodeStack };
@@ -12,8 +12,8 @@ function pixelsToPercent(pixels, axis) {
12
12
  * borderRadius in both states. If we animate between the two in pixels that will trigger
13
13
  * a paint each time. If we animate between the two in percentage we'll avoid a paint.
14
14
  */
15
- var correctBorderRadius = {
16
- correct: function (latest, node) {
15
+ const correctBorderRadius = {
16
+ correct: (latest, node) => {
17
17
  if (!node.target)
18
18
  return latest;
19
19
  /**
@@ -32,9 +32,9 @@ var correctBorderRadius = {
32
32
  * If latest is a number, it's a pixel value. We use the current viewportBox to calculate that
33
33
  * pixel value as a percentage of each axis
34
34
  */
35
- var x = pixelsToPercent(latest, node.target.x);
36
- var y = pixelsToPercent(latest, node.target.y);
37
- return "".concat(x, "% ").concat(y, "%");
35
+ const x = pixelsToPercent(latest, node.target.x);
36
+ const y = pixelsToPercent(latest, node.target.y);
37
+ return `${x}% ${y}%`;
38
38
  },
39
39
  };
40
40
 
@@ -2,31 +2,30 @@ import { mix } from 'popmotion';
2
2
  import { complex } from 'style-value-types';
3
3
  import { cssVariableRegex } from '../../render/dom/utils/css-variables-conversion.mjs';
4
4
 
5
- var varToken = "_$css";
6
- var correctBoxShadow = {
7
- correct: function (latest, _a) {
8
- var treeScale = _a.treeScale, projectionDelta = _a.projectionDelta;
9
- var original = latest;
5
+ const varToken = "_$css";
6
+ const correctBoxShadow = {
7
+ correct: (latest, { treeScale, projectionDelta }) => {
8
+ const original = latest;
10
9
  /**
11
10
  * We need to first strip and store CSS variables from the string.
12
11
  */
13
- var containsCSSVariables = latest.includes("var(");
14
- var cssVariables = [];
12
+ const containsCSSVariables = latest.includes("var(");
13
+ const cssVariables = [];
15
14
  if (containsCSSVariables) {
16
- latest = latest.replace(cssVariableRegex, function (match) {
15
+ latest = latest.replace(cssVariableRegex, (match) => {
17
16
  cssVariables.push(match);
18
17
  return varToken;
19
18
  });
20
19
  }
21
- var shadow = complex.parse(latest);
20
+ const shadow = complex.parse(latest);
22
21
  // TODO: Doesn't support multiple shadows
23
22
  if (shadow.length > 5)
24
23
  return original;
25
- var template = complex.createTransformer(latest);
26
- var offset = typeof shadow[0] !== "number" ? 1 : 0;
24
+ const template = complex.createTransformer(latest);
25
+ const offset = typeof shadow[0] !== "number" ? 1 : 0;
27
26
  // Calculate the overall context scale
28
- var xScale = projectionDelta.x.scale * treeScale.x;
29
- var yScale = projectionDelta.y.scale * treeScale.y;
27
+ const xScale = projectionDelta.x.scale * treeScale.x;
28
+ const yScale = projectionDelta.y.scale * treeScale.y;
30
29
  shadow[0 + offset] /= xScale;
31
30
  shadow[1 + offset] /= yScale;
32
31
  /**
@@ -35,19 +34,19 @@ var correctBoxShadow = {
35
34
  * We could potentially improve the outcome of this by incorporating the ratio between
36
35
  * the two scales.
37
36
  */
38
- var averageScale = mix(xScale, yScale, 0.5);
37
+ const averageScale = mix(xScale, yScale, 0.5);
39
38
  // Blur
40
39
  if (typeof shadow[2 + offset] === "number")
41
40
  shadow[2 + offset] /= averageScale;
42
41
  // Spread
43
42
  if (typeof shadow[3 + offset] === "number")
44
43
  shadow[3 + offset] /= averageScale;
45
- var output = template(shadow);
44
+ let output = template(shadow);
46
45
  if (containsCSSVariables) {
47
- var i_1 = 0;
48
- output = output.replace(varToken, function () {
49
- var cssVariable = cssVariables[i_1];
50
- i_1++;
46
+ let i = 0;
47
+ output = output.replace(varToken, () => {
48
+ const cssVariable = cssVariables[i];
49
+ i++;
51
50
  return cssVariable;
52
51
  });
53
52
  }
@@ -1,4 +1,4 @@
1
- var scaleCorrectors = {};
1
+ const scaleCorrectors = {};
2
2
  function addScaleCorrector(correctors) {
3
3
  Object.assign(scaleCorrectors, correctors);
4
4
  }
@@ -1,4 +1,4 @@
1
- var identityProjection = "translate3d(0px, 0px, 0) scale(1, 1) scale(1, 1)";
1
+ const identityProjection = "translate3d(0px, 0px, 0) scale(1, 1) scale(1, 1)";
2
2
  function buildProjectionTransform(delta, treeScale, latestTransform) {
3
3
  /**
4
4
  * The translations we use to calculate are always relative to the viewport coordinate space.
@@ -6,30 +6,30 @@ function buildProjectionTransform(delta, treeScale, latestTransform) {
6
6
  * For instance if we have a treeScale (the culmination of all parent scales) of 0.5 and we need
7
7
  * to move an element 100 pixels, we actually need to move it 200 in within that scaled space.
8
8
  */
9
- var xTranslate = delta.x.translate / treeScale.x;
10
- var yTranslate = delta.y.translate / treeScale.y;
11
- var transform = "translate3d(".concat(xTranslate, "px, ").concat(yTranslate, "px, 0) ");
9
+ const xTranslate = delta.x.translate / treeScale.x;
10
+ const yTranslate = delta.y.translate / treeScale.y;
11
+ let transform = `translate3d(${xTranslate}px, ${yTranslate}px, 0) `;
12
12
  /**
13
13
  * Apply scale correction for the tree transform.
14
14
  * This will apply scale to the screen-orientated axes.
15
15
  */
16
- transform += "scale(".concat(1 / treeScale.x, ", ").concat(1 / treeScale.y, ") ");
16
+ transform += `scale(${1 / treeScale.x}, ${1 / treeScale.y}) `;
17
17
  if (latestTransform) {
18
- var rotate = latestTransform.rotate, rotateX = latestTransform.rotateX, rotateY = latestTransform.rotateY;
18
+ const { rotate, rotateX, rotateY } = latestTransform;
19
19
  if (rotate)
20
- transform += "rotate(".concat(rotate, "deg) ");
20
+ transform += `rotate(${rotate}deg) `;
21
21
  if (rotateX)
22
- transform += "rotateX(".concat(rotateX, "deg) ");
22
+ transform += `rotateX(${rotateX}deg) `;
23
23
  if (rotateY)
24
- transform += "rotateY(".concat(rotateY, "deg) ");
24
+ transform += `rotateY(${rotateY}deg) `;
25
25
  }
26
26
  /**
27
27
  * Apply scale to match the size of the element to the size we want it.
28
28
  * This will apply scale to the element-orientated axes.
29
29
  */
30
- var elementScaleX = delta.x.scale * treeScale.x;
31
- var elementScaleY = delta.y.scale * treeScale.y;
32
- transform += "scale(".concat(elementScaleX, ", ").concat(elementScaleY, ")");
30
+ const elementScaleX = delta.x.scale * treeScale.x;
31
+ const elementScaleY = delta.y.scale * treeScale.y;
32
+ transform += `scale(${elementScaleX}, ${elementScaleY})`;
33
33
  return transform === identityProjection ? "none" : transform;
34
34
  }
35
35
 
@@ -2,8 +2,8 @@ import * as React from 'react';
2
2
  import { rootProjectionNode } from './node/HTMLProjectionNode.mjs';
3
3
 
4
4
  function useResetProjection() {
5
- var reset = React.useCallback(function () {
6
- var root = rootProjectionNode.current;
5
+ const reset = React.useCallback(() => {
6
+ const root = rootProjectionNode.current;
7
7
  if (!root)
8
8
  return;
9
9
  root.resetTree();
@@ -1,8 +1,7 @@
1
1
  function isIdentityScale(scale) {
2
2
  return scale === undefined || scale === 1;
3
3
  }
4
- function hasScale(_a) {
5
- var scale = _a.scale, scaleX = _a.scaleX, scaleY = _a.scaleY;
4
+ function hasScale({ scale, scaleX, scaleY }) {
6
5
  return (!isIdentityScale(scale) ||
7
6
  !isIdentityScale(scaleX) ||
8
7
  !isIdentityScale(scaleY));
@@ -5,8 +5,8 @@ function measureViewportBox(instance, transformPoint) {
5
5
  return convertBoundingBoxToBox(transformBoxPoints(instance.getBoundingClientRect(), transformPoint));
6
6
  }
7
7
  function measurePageBox(element, rootProjectionNode, transformPagePoint) {
8
- var viewportBox = measureViewportBox(element, transformPagePoint);
9
- var scroll = rootProjectionNode.scroll;
8
+ const viewportBox = measureViewportBox(element, transformPagePoint);
9
+ const { scroll } = rootProjectionNode;
10
10
  if (scroll) {
11
11
  translateAxis(viewportBox.x, scroll.x);
12
12
  translateAxis(viewportBox.y, scroll.y);
@@ -2,7 +2,7 @@ import { htmlVisualElement } from '../html/visual-element.mjs';
2
2
  import { svgVisualElement } from '../svg/visual-element.mjs';
3
3
  import { isSVGComponent } from './utils/is-svg-component.mjs';
4
4
 
5
- var createDomVisualElement = function (Component, options) {
5
+ const createDomVisualElement = (Component, options) => {
6
6
  return isSVGComponent(Component)
7
7
  ? svgVisualElement(options, { enableHardwareAcceleration: false })
8
8
  : htmlVisualElement(options, { enableHardwareAcceleration: true });
@@ -1,4 +1,3 @@
1
- import { __assign } from 'tslib';
2
1
  import { animations } from '../../motion/features/animations.mjs';
3
2
  import { gestureAnimations } from '../../motion/features/gestures.mjs';
4
3
  import { createDomVisualElement } from './create-visual-element.mjs';
@@ -6,6 +5,6 @@ import { createDomVisualElement } from './create-visual-element.mjs';
6
5
  /**
7
6
  * @public
8
7
  */
9
- var domAnimation = __assign(__assign({ renderer: createDomVisualElement }, animations), gestureAnimations);
8
+ const domAnimation = Object.assign(Object.assign({ renderer: createDomVisualElement }, animations), gestureAnimations);
10
9
 
11
10
  export { domAnimation };
@@ -1,4 +1,3 @@
1
- import { __assign } from 'tslib';
2
1
  import { drag } from '../../motion/features/drag.mjs';
3
2
  import { layoutFeatures } from '../../motion/features/layout/index.mjs';
4
3
  import { domAnimation } from './features-animation.mjs';
@@ -7,6 +6,6 @@ import { HTMLProjectionNode } from '../../projection/node/HTMLProjectionNode.mjs
7
6
  /**
8
7
  * @public
9
8
  */
10
- var domMax = __assign(__assign(__assign(__assign({}, domAnimation), drag), layoutFeatures), { projectionNodeConstructor: HTMLProjectionNode });
9
+ const domMax = Object.assign(Object.assign(Object.assign(Object.assign({}, domAnimation), drag), layoutFeatures), { projectionNodeConstructor: HTMLProjectionNode });
11
10
 
12
11
  export { domMax };
@@ -4,6 +4,6 @@ import { createDomMotionConfig } from './utils/create-config.mjs';
4
4
  /**
5
5
  * @public
6
6
  */
7
- var m = createMotionProxy(createDomMotionConfig);
7
+ const m = createMotionProxy(createDomMotionConfig);
8
8
 
9
9
  export { m };
@@ -15,8 +15,7 @@ import { createMotionComponent } from '../../motion/index.mjs';
15
15
  * @public
16
16
  */
17
17
  function createMotionProxy(createConfig) {
18
- function custom(Component, customMotionComponentConfig) {
19
- if (customMotionComponentConfig === void 0) { customMotionComponentConfig = {}; }
18
+ function custom(Component, customMotionComponentConfig = {}) {
20
19
  return createMotionComponent(createConfig(Component, customMotionComponentConfig));
21
20
  }
22
21
  if (typeof Proxy === "undefined") {
@@ -26,14 +25,14 @@ function createMotionProxy(createConfig) {
26
25
  * A cache of generated `motion` components, e.g `motion.div`, `motion.input` etc.
27
26
  * Rather than generating them anew every render.
28
27
  */
29
- var componentCache = new Map();
28
+ const componentCache = new Map();
30
29
  return new Proxy(custom, {
31
30
  /**
32
31
  * Called when `motion` is referenced with a prop: `motion.div`, `motion.input` etc.
33
32
  * The prop name is passed through as `key` and we can use that to generate a `motion`
34
33
  * DOM component with that name.
35
34
  */
36
- get: function (_target, key) {
35
+ get: (_target, key) => {
37
36
  /**
38
37
  * If this element doesn't exist in the component cache, create it and cache.
39
38
  */
@@ -1,4 +1,3 @@
1
- import { __assign } from 'tslib';
2
1
  import { createMotionComponent } from '../../motion/index.mjs';
3
2
  import { createMotionProxy } from './motion-proxy.mjs';
4
3
  import { createDomMotionConfig } from './utils/create-config.mjs';
@@ -9,16 +8,14 @@ import { createDomVisualElement } from './create-visual-element.mjs';
9
8
  import { layoutFeatures } from '../../motion/features/layout/index.mjs';
10
9
  import { HTMLProjectionNode } from '../../projection/node/HTMLProjectionNode.mjs';
11
10
 
12
- var featureBundle = __assign(__assign(__assign(__assign({}, animations), gestureAnimations), drag), layoutFeatures);
11
+ const featureBundle = Object.assign(Object.assign(Object.assign(Object.assign({}, animations), gestureAnimations), drag), layoutFeatures);
13
12
  /**
14
13
  * HTML & SVG components, optimised for use with gestures and animation. These can be used as
15
14
  * drop-in replacements for any HTML & SVG component, all CSS & SVG properties are supported.
16
15
  *
17
16
  * @public
18
17
  */
19
- var motion = /*@__PURE__*/ createMotionProxy(function (Component, config) {
20
- return createDomMotionConfig(Component, config, featureBundle, createDomVisualElement, HTMLProjectionNode);
21
- });
18
+ const motion = /*@__PURE__*/ createMotionProxy((Component, config) => createDomMotionConfig(Component, config, featureBundle, createDomVisualElement, HTMLProjectionNode));
22
19
  /**
23
20
  * Create a DOM `motion` component with the provided string. This is primarily intended
24
21
  * as a full alternative to `motion` for consumers who have to support environments that don't
@@ -1,20 +1,17 @@
1
- import { __assign } from 'tslib';
2
1
  import { createElement } from 'react';
3
2
  import { useHTMLProps } from '../html/use-props.mjs';
4
3
  import { filterProps } from './utils/filter-props.mjs';
5
4
  import { isSVGComponent } from './utils/is-svg-component.mjs';
6
5
  import { useSVGProps } from '../svg/use-props.mjs';
7
6
 
8
- function createUseRender(forwardMotionProps) {
9
- if (forwardMotionProps === void 0) { forwardMotionProps = false; }
10
- var useRender = function (Component, props, projectionId, ref, _a, isStatic) {
11
- var latestValues = _a.latestValues;
12
- var useVisualProps = isSVGComponent(Component)
7
+ function createUseRender(forwardMotionProps = false) {
8
+ const useRender = (Component, props, projectionId, ref, { latestValues }, isStatic) => {
9
+ const useVisualProps = isSVGComponent(Component)
13
10
  ? useSVGProps
14
11
  : useHTMLProps;
15
- var visualProps = useVisualProps(props, latestValues, isStatic);
16
- var filteredProps = filterProps(props, typeof Component === "string", forwardMotionProps);
17
- var elementProps = __assign(__assign(__assign({}, filteredProps), visualProps), { ref: ref });
12
+ const visualProps = useVisualProps(props, latestValues, isStatic);
13
+ const filteredProps = filterProps(props, typeof Component === "string", forwardMotionProps);
14
+ const elementProps = Object.assign(Object.assign(Object.assign({}, filteredProps), visualProps), { ref });
18
15
  if (projectionId) {
19
16
  elementProps["data-projection-id"] = projectionId;
20
17
  }
@@ -1,10 +1,8 @@
1
- var CAMEL_CASE_PATTERN = /([a-z])([A-Z])/g;
2
- var REPLACE_TEMPLATE = "$1-$2";
1
+ const CAMEL_CASE_PATTERN = /([a-z])([A-Z])/g;
2
+ const REPLACE_TEMPLATE = "$1-$2";
3
3
  /**
4
4
  * Convert camelCase to dash-case properties.
5
5
  */
6
- var camelToDash = function (str) {
7
- return str.replace(CAMEL_CASE_PATTERN, REPLACE_TEMPLATE).toLowerCase();
8
- };
6
+ const camelToDash = (str) => str.replace(CAMEL_CASE_PATTERN, REPLACE_TEMPLATE).toLowerCase();
9
7
 
10
8
  export { camelToDash };
@@ -1,15 +1,15 @@
1
- import { __assign } from 'tslib';
2
1
  import { isSVGComponent } from './is-svg-component.mjs';
3
2
  import { createUseRender } from '../use-render.mjs';
4
3
  import { svgMotionConfig } from '../../svg/config-motion.mjs';
5
4
  import { htmlMotionConfig } from '../../html/config-motion.mjs';
6
5
 
7
- function createDomMotionConfig(Component, _a, preloadedFeatures, createVisualElement, projectionNodeConstructor) {
8
- var _b = _a.forwardMotionProps, forwardMotionProps = _b === void 0 ? false : _b;
9
- var baseConfig = isSVGComponent(Component)
6
+ function createDomMotionConfig(Component, { forwardMotionProps = false }, preloadedFeatures, createVisualElement, projectionNodeConstructor) {
7
+ const baseConfig = isSVGComponent(Component)
10
8
  ? svgMotionConfig
11
9
  : htmlMotionConfig;
12
- return __assign(__assign({}, baseConfig), { preloadedFeatures: preloadedFeatures, useRender: createUseRender(forwardMotionProps), createVisualElement: createVisualElement, projectionNodeConstructor: projectionNodeConstructor, Component: Component });
10
+ return Object.assign(Object.assign({}, baseConfig), { preloadedFeatures, useRender: createUseRender(forwardMotionProps), createVisualElement,
11
+ projectionNodeConstructor,
12
+ Component });
13
13
  }
14
14
 
15
15
  export { createDomMotionConfig };
@@ -1,4 +1,4 @@
1
- import { __rest, __assign, __read } from 'tslib';
1
+ import { __rest } from 'tslib';
2
2
  import { invariant } from 'hey-listen';
3
3
 
4
4
  function isCSSVariable(value) {
@@ -13,24 +13,23 @@ function isCSSVariable(value) {
13
13
  *
14
14
  * @param current
15
15
  */
16
- var cssVariableRegex = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/;
16
+ const cssVariableRegex = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/;
17
17
  function parseCSSVariable(current) {
18
- var match = cssVariableRegex.exec(current);
18
+ const match = cssVariableRegex.exec(current);
19
19
  if (!match)
20
20
  return [,];
21
- var _a = __read(match, 3), token = _a[1], fallback = _a[2];
21
+ const [, token, fallback] = match;
22
22
  return [token, fallback];
23
23
  }
24
- var maxDepth = 4;
25
- function getVariableValue(current, element, depth) {
26
- if (depth === void 0) { depth = 1; }
27
- invariant(depth <= maxDepth, "Max CSS variable fallback depth detected in property \"".concat(current, "\". This may indicate a circular fallback dependency."));
28
- var _a = __read(parseCSSVariable(current), 2), token = _a[0], fallback = _a[1];
24
+ const maxDepth = 4;
25
+ function getVariableValue(current, element, depth = 1) {
26
+ invariant(depth <= maxDepth, `Max CSS variable fallback depth detected in property "${current}". This may indicate a circular fallback dependency.`);
27
+ const [token, fallback] = parseCSSVariable(current);
29
28
  // No CSS variable detected
30
29
  if (!token)
31
30
  return;
32
31
  // Attempt to read this CSS variable off the element
33
- var resolved = window.getComputedStyle(element).getPropertyValue(token);
32
+ const resolved = window.getComputedStyle(element).getPropertyValue(token);
34
33
  if (resolved) {
35
34
  return resolved.trim();
36
35
  }
@@ -50,30 +49,30 @@ function getVariableValue(current, element, depth) {
50
49
  function resolveCSSVariables(visualElement, _a, transitionEnd) {
51
50
  var _b;
52
51
  var target = __rest(_a, []);
53
- var element = visualElement.getInstance();
52
+ const element = visualElement.getInstance();
54
53
  if (!(element instanceof Element))
55
- return { target: target, transitionEnd: transitionEnd };
54
+ return { target, transitionEnd };
56
55
  // If `transitionEnd` isn't `undefined`, clone it. We could clone `target` and `transitionEnd`
57
56
  // only if they change but I think this reads clearer and this isn't a performance-critical path.
58
57
  if (transitionEnd) {
59
- transitionEnd = __assign({}, transitionEnd);
58
+ transitionEnd = Object.assign({}, transitionEnd);
60
59
  }
61
60
  // Go through existing `MotionValue`s and ensure any existing CSS variables are resolved
62
- visualElement.forEachValue(function (value) {
63
- var current = value.get();
61
+ visualElement.forEachValue((value) => {
62
+ const current = value.get();
64
63
  if (!isCSSVariable(current))
65
64
  return;
66
- var resolved = getVariableValue(current, element);
65
+ const resolved = getVariableValue(current, element);
67
66
  if (resolved)
68
67
  value.set(resolved);
69
68
  });
70
69
  // Cycle through every target property and resolve CSS variables. Currently
71
70
  // we only read single-var properties like `var(--foo)`, not `calc(var(--foo) + 20px)`
72
- for (var key in target) {
73
- var current = target[key];
71
+ for (const key in target) {
72
+ const current = target[key];
74
73
  if (!isCSSVariable(current))
75
74
  continue;
76
- var resolved = getVariableValue(current, element);
75
+ const resolved = getVariableValue(current, element);
77
76
  if (!resolved)
78
77
  continue;
79
78
  // Clone target if it hasn't already been
@@ -84,7 +83,7 @@ function resolveCSSVariables(visualElement, _a, transitionEnd) {
84
83
  if (transitionEnd)
85
84
  (_b = transitionEnd[key]) !== null && _b !== void 0 ? _b : (transitionEnd[key] = current);
86
85
  }
87
- return { target: target, transitionEnd: transitionEnd };
86
+ return { target, transitionEnd };
88
87
  }
89
88
 
90
89
  export { cssVariableRegex, parseCSSVariable, resolveCSSVariables };
@@ -1,13 +1,11 @@
1
1
  import { isValidMotionProp } from '../../../motion/utils/valid-prop.mjs';
2
2
 
3
- var shouldForward = function (key) { return !isValidMotionProp(key); };
3
+ let shouldForward = (key) => !isValidMotionProp(key);
4
4
  function loadExternalIsValidProp(isValidProp) {
5
5
  if (!isValidProp)
6
6
  return;
7
7
  // Explicitly filter our events
8
- shouldForward = function (key) {
9
- return key.startsWith("on") ? !isValidMotionProp(key) : isValidProp(key);
10
- };
8
+ shouldForward = (key) => key.startsWith("on") ? !isValidMotionProp(key) : isValidProp(key);
11
9
  }
12
10
  /**
13
11
  * Emotion and Styled Components both allow users to pass through arbitrary props to their components
@@ -34,8 +32,8 @@ catch (_a) {
34
32
  // We don't need to actually do anything here - the fallback is the existing `isPropValid`.
35
33
  }
36
34
  function filterProps(props, isDom, forwardMotionProps) {
37
- var filteredProps = {};
38
- for (var key in props) {
35
+ const filteredProps = {};
36
+ for (const key in props) {
39
37
  if (shouldForward(key) ||
40
38
  (forwardMotionProps === true && isValidMotionProp(key)) ||
41
39
  (!isDom && !isValidMotionProp(key)) ||
@@ -5,8 +5,8 @@ import { unitConversion } from './unit-conversion.mjs';
5
5
  * Parse a DOM variant to make it animatable. This involves resolving CSS variables
6
6
  * and ensuring animations like "20%" => "calc(50vw)" are performed in pixels.
7
7
  */
8
- var parseDomVariant = function (visualElement, target, origin, transitionEnd) {
9
- var resolved = resolveCSSVariables(visualElement, target, transitionEnd);
8
+ const parseDomVariant = (visualElement, target, origin, transitionEnd) => {
9
+ const resolved = resolveCSSVariables(visualElement, target, transitionEnd);
10
10
  target = resolved.target;
11
11
  transitionEnd = resolved.transitionEnd;
12
12
  return unitConversion(visualElement, target, origin, transitionEnd);