motion 11.12.0 → 11.13.0

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 (55) hide show
  1. package/.turbo/turbo-build.log +14 -14
  2. package/dist/cjs/index.js +54 -48
  3. package/dist/cjs/mini.js +21 -25
  4. package/dist/cjs/react-client.js +142 -104
  5. package/dist/cjs/react-mini.js +21 -25
  6. package/dist/es/framer-motion/dist/es/animation/animate/resolve-subjects.mjs +1 -1
  7. package/dist/es/framer-motion/dist/es/animation/animate/subject.mjs +1 -1
  8. package/dist/es/framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs +2 -1
  9. package/dist/es/framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs +1 -1
  10. package/dist/es/framer-motion/dist/es/animation/animators/utils/can-animate.mjs +1 -1
  11. package/dist/es/framer-motion/dist/es/animation/animators/waapi/NativeAnimation.mjs +2 -2
  12. package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +2 -2
  13. package/dist/es/framer-motion/dist/es/animation/generators/spring/find.mjs +1 -1
  14. package/dist/es/framer-motion/dist/es/animation/hooks/animation-controls.mjs +1 -1
  15. package/dist/es/framer-motion/dist/es/animation/optimized-appear/start.mjs +2 -1
  16. package/dist/es/framer-motion/dist/es/components/AnimatePresence/index.mjs +1 -1
  17. package/dist/es/framer-motion/dist/es/components/AnimateSharedLayout.mjs +1 -1
  18. package/dist/es/framer-motion/dist/es/components/Reorder/Group.mjs +1 -1
  19. package/dist/es/framer-motion/dist/es/components/Reorder/Item.mjs +1 -1
  20. package/dist/es/framer-motion/dist/es/easing/cubic-bezier.mjs +2 -1
  21. package/dist/es/framer-motion/dist/es/easing/utils/map.mjs +2 -2
  22. package/dist/es/framer-motion/dist/es/events/event-info.mjs +3 -3
  23. package/dist/es/framer-motion/dist/es/frameloop/frame.mjs +2 -1
  24. package/dist/es/framer-motion/dist/es/gestures/drag/VisualElementDragControls.mjs +12 -15
  25. package/dist/es/framer-motion/dist/es/gestures/drag/index.mjs +2 -1
  26. package/dist/es/framer-motion/dist/es/gestures/hover.mjs +18 -22
  27. package/dist/es/framer-motion/dist/es/gestures/pan/index.mjs +2 -1
  28. package/dist/es/framer-motion/dist/es/gestures/press.mjs +3 -2
  29. package/dist/es/framer-motion/dist/es/motion/index.mjs +1 -1
  30. package/dist/es/framer-motion/dist/es/projection/animation/mix-values.mjs +2 -1
  31. package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +2 -1
  32. package/dist/es/framer-motion/dist/es/render/dom/resize/handle-element.mjs +1 -1
  33. package/dist/es/framer-motion/dist/es/render/dom/scroll/index.mjs +2 -1
  34. package/dist/es/framer-motion/dist/es/render/dom/utils/css-variables-conversion.mjs +1 -1
  35. package/dist/es/framer-motion/dist/es/render/dom/viewport/index.mjs +1 -1
  36. package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
  37. package/dist/es/framer-motion/dist/es/utils/interpolate.mjs +2 -2
  38. package/dist/es/framer-motion/dist/es/utils/mix/color.mjs +1 -1
  39. package/dist/es/framer-motion/dist/es/utils/mix/complex.mjs +1 -1
  40. package/dist/es/framer-motion/dist/es/value/index.mjs +1 -1
  41. package/dist/es/framer-motion/dist/es/value/use-inverted-scale.mjs +1 -1
  42. package/dist/es/framer-motion/dist/es/value/use-scroll.mjs +1 -1
  43. package/dist/es/motion/lib/index.mjs +3 -1
  44. package/dist/es/motion/lib/react.mjs +3 -2
  45. package/dist/es/motion-dom/dist/es/gestures/drag/state/is-active.mjs +9 -0
  46. package/dist/es/motion-dom/dist/es/gestures/drag/state/set-active.mjs +28 -0
  47. package/dist/es/motion-dom/dist/es/gestures/hover.mjs +46 -0
  48. package/dist/es/motion-dom/dist/es/utils/resolve-elements.mjs +22 -0
  49. package/dist/motion.dev.js +54 -48
  50. package/dist/motion.js +1 -1
  51. package/package.json +3 -3
  52. package/dist/es/framer-motion/dist/es/gestures/drag/utils/lock.mjs +0 -53
  53. package/dist/es/framer-motion/dist/es/render/dom/utils/resolve-element.mjs +0 -28
  54. /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/errors.mjs +0 -0
  55. /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/noop.mjs +0 -0
@@ -1,45 +1,45 @@
1
1
  
2
2
  lib/index.js → dist/motion.dev.js...
3
- created dist/motion.dev.js in 737ms
3
+ created dist/motion.dev.js in 563ms
4
4
  
5
5
  lib/index.js → dist/motion.js...
6
- created dist/motion.js in 825ms
6
+ created dist/motion.js in 897ms
7
7
  
8
8
  lib/index.js → dist/cjs...
9
- created dist/cjs in 227ms
9
+ created dist/cjs in 237ms
10
10
  
11
11
  lib/react-client.js → dist/cjs...
12
12
  created dist/cjs in 271ms
13
13
  
14
14
  lib/react.js → dist/cjs...
15
- created dist/cjs in 3ms
15
+ created dist/cjs in 2ms
16
16
  
17
17
  lib/mini.js → dist/cjs...
18
- created dist/cjs in 24ms
18
+ created dist/cjs in 64ms
19
19
  
20
20
  lib/react-mini.js → dist/cjs...
21
- created dist/cjs in 34ms
21
+ created dist/cjs in 76ms
22
22
  
23
23
  lib/react-m.js → dist/cjs...
24
- created dist/cjs in 70ms
24
+ created dist/cjs in 55ms
25
25
  
26
26
  lib/index.js, lib/mini.js, lib/react.js, lib/react-mini.js, lib/react-client.js, lib/react-m.js → dist/es...
27
- created dist/es in 636ms
27
+ created dist/es in 543ms
28
28
  
29
29
  types/index.d.ts → dist/index.d.ts...
30
- created dist/index.d.ts in 21ms
30
+ created dist/index.d.ts in 8ms
31
31
  
32
32
  types/react.d.ts → dist/react.d.ts...
33
- created dist/react.d.ts in 13ms
33
+ created dist/react.d.ts in 4ms
34
34
  
35
35
  types/react-mini.d.ts → dist/react-mini.d.ts...
36
- created dist/react-mini.d.ts in 12ms
36
+ created dist/react-mini.d.ts in 2ms
37
37
  
38
38
  types/react-m.d.ts → dist/react-m.d.ts...
39
- created dist/react-m.d.ts in 58ms
39
+ created dist/react-m.d.ts in 1ms
40
40
  
41
41
  types/mini.d.ts → dist/mini.d.ts...
42
- created dist/mini.d.ts in 13ms
42
+ created dist/mini.d.ts in 2ms
43
43
  
44
44
  types/react-client.d.ts → dist/react-client.d.ts...
45
- created dist/react-client.d.ts in 6ms
45
+ created dist/react-client.d.ts in 3ms
package/dist/cjs/index.js CHANGED
@@ -2,6 +2,52 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ const noop = (any) => any;
6
+
7
+ let warning = noop;
8
+ exports.invariant = noop;
9
+ if (process.env.NODE_ENV !== "production") {
10
+ warning = (check, message) => {
11
+ if (!check && typeof console !== "undefined") {
12
+ console.warn(message);
13
+ }
14
+ };
15
+ exports.invariant = (check, message) => {
16
+ if (!check) {
17
+ throw new Error(message);
18
+ }
19
+ };
20
+ }
21
+
22
+ function resolveElements(elementOrSelector, scope, selectorCache) {
23
+ var _a;
24
+ if (elementOrSelector instanceof Element) {
25
+ return [elementOrSelector];
26
+ }
27
+ else if (typeof elementOrSelector === "string") {
28
+ let root = document;
29
+ if (scope) {
30
+ // TODO: Refactor to utils package
31
+ // invariant(
32
+ // Boolean(scope.current),
33
+ // "Scope provided, but no element detected."
34
+ // )
35
+ root = scope.current;
36
+ }
37
+ const elements = (_a = selectorCache === null || selectorCache === void 0 ? void 0 : selectorCache[elementOrSelector]) !== null && _a !== void 0 ? _a : root.querySelectorAll(elementOrSelector);
38
+ return elements ? Array.from(elements) : [];
39
+ }
40
+ return Array.from(elementOrSelector);
41
+ }
42
+
43
+ const isDragging = {
44
+ x: false,
45
+ y: false,
46
+ };
47
+ function isDragActive() {
48
+ return isDragging.y;
49
+ }
50
+
5
51
  function addUniqueItem(arr, item) {
6
52
  if (arr.indexOf(item) === -1)
7
53
  arr.push(item);
@@ -74,8 +120,6 @@ const MotionGlobalConfig = {
74
120
  useManualTiming: false,
75
121
  };
76
122
 
77
- const noop = (any) => any;
78
-
79
123
  function createRenderStep(runNextFrame) {
80
124
  /**
81
125
  * We create and reuse two queues, one to queue jobs for the current frame
@@ -279,7 +323,7 @@ class MotionValue {
279
323
  * This will be replaced by the build step with the latest version number.
280
324
  * When MotionValues are provided to motion components, warn if versions are mixed.
281
325
  */
282
- this.version = "11.12.0";
326
+ this.version = "11.13.0";
283
327
  /**
284
328
  * Tracks whether this value can output a velocity. Currently this is only true
285
329
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -690,21 +734,6 @@ function calcGeneratorVelocity(resolveValue, t, current) {
690
734
  return velocityPerSecond(current - resolveValue(prevT), t - prevT);
691
735
  }
692
736
 
693
- exports.warning = noop;
694
- exports.invariant = noop;
695
- if (process.env.NODE_ENV !== "production") {
696
- exports.warning = (check, message) => {
697
- if (!check && typeof console !== "undefined") {
698
- console.warn(message);
699
- }
700
- };
701
- exports.invariant = (check, message) => {
702
- if (!check) {
703
- throw new Error(message);
704
- }
705
- };
706
- }
707
-
708
737
  const clamp = (min, max, v) => {
709
738
  if (v > max)
710
739
  return max;
@@ -743,7 +772,7 @@ const safeMin = 0.001;
743
772
  function findSpring({ duration = springDefaults.duration, bounce = springDefaults.bounce, velocity = springDefaults.velocity, mass = springDefaults.mass, }) {
744
773
  let envelope;
745
774
  let derivative;
746
- exports.warning(duration <= secondsToMilliseconds(springDefaults.maxDuration), "Spring duration must be 10 seconds or less");
775
+ warning(duration <= secondsToMilliseconds(springDefaults.maxDuration), "Spring duration must be 10 seconds or less");
747
776
  let dampingRatio = 1 - bounce;
748
777
  /**
749
778
  * Restrict dampingRatio and duration to within acceptable ranges.
@@ -1045,31 +1074,6 @@ function defaultOffset$1(arr) {
1045
1074
 
1046
1075
  const isMotionValue = (value) => Boolean(value && value.getVelocity);
1047
1076
 
1048
- function resolveElements(elements, scope, selectorCache) {
1049
- var _a;
1050
- if (typeof elements === "string") {
1051
- let root = document;
1052
- if (scope) {
1053
- exports.invariant(Boolean(scope.current), "Scope provided, but no element detected.");
1054
- root = scope.current;
1055
- }
1056
- if (selectorCache) {
1057
- (_a = selectorCache[elements]) !== null && _a !== void 0 ? _a : (selectorCache[elements] = root.querySelectorAll(elements));
1058
- elements = selectorCache[elements];
1059
- }
1060
- else {
1061
- elements = root.querySelectorAll(elements);
1062
- }
1063
- }
1064
- else if (elements instanceof Element) {
1065
- elements = [elements];
1066
- }
1067
- /**
1068
- * Return an empty array
1069
- */
1070
- return Array.from(elements || []);
1071
- }
1072
-
1073
1077
  function isDOMKeyframes(keyframes) {
1074
1078
  return typeof keyframes === "object" && !Array.isArray(keyframes);
1075
1079
  }
@@ -2439,7 +2443,7 @@ function canAnimate(keyframes, name, type, velocity) {
2439
2443
  const targetKeyframe = keyframes[keyframes.length - 1];
2440
2444
  const isOriginAnimatable = isAnimatable(originKeyframe, name);
2441
2445
  const isTargetAnimatable = isAnimatable(targetKeyframe, name);
2442
- exports.warning(isOriginAnimatable === isTargetAnimatable, `You are trying to animate ${name} from "${originKeyframe}" to "${targetKeyframe}". ${originKeyframe} is not an animatable value - to enable this animation set ${originKeyframe} to a value animatable to ${targetKeyframe} via the \`style\` property.`);
2446
+ warning(isOriginAnimatable === isTargetAnimatable, `You are trying to animate ${name} from "${originKeyframe}" to "${targetKeyframe}". ${originKeyframe} is not an animatable value - to enable this animation set ${originKeyframe} to a value animatable to ${targetKeyframe} via the \`style\` property.`);
2443
2447
  // Always skip if any of these are true
2444
2448
  if (!isOriginAnimatable || !isTargetAnimatable) {
2445
2449
  return false;
@@ -2742,7 +2746,7 @@ const colorTypes = [hex, rgba, hsla];
2742
2746
  const getColorType = (v) => colorTypes.find((type) => type.test(v));
2743
2747
  function asRGBA(color) {
2744
2748
  const type = getColorType(color);
2745
- exports.warning(Boolean(type), `'${color}' is not an animatable color. Use the equivalent color code instead.`);
2749
+ warning(Boolean(type), `'${color}' is not an animatable color. Use the equivalent color code instead.`);
2746
2750
  if (!Boolean(type))
2747
2751
  return false;
2748
2752
  let model = type.parse(color);
@@ -2861,7 +2865,7 @@ const mixComplex = (origin, target) => {
2861
2865
  return pipe(mixArray(matchOrder(originStats, targetStats), targetStats.values), template);
2862
2866
  }
2863
2867
  else {
2864
- exports.warning(true, `Complex values '${origin}' and '${target}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`);
2868
+ warning(true, `Complex values '${origin}' and '${target}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`);
2865
2869
  return mixImmediate(origin, target);
2866
2870
  }
2867
2871
  };
@@ -4156,7 +4160,7 @@ function updateMotionValuesFromProps(element, next, prev) {
4156
4160
  * and warn against mismatches.
4157
4161
  */
4158
4162
  if (process.env.NODE_ENV === "development") {
4159
- warnOnce(nextValue.version === "11.12.0", `Attempting to mix Motion versions ${nextValue.version} with 11.12.0 may not work as expected.`);
4163
+ warnOnce(nextValue.version === "11.13.0", `Attempting to mix Motion versions ${nextValue.version} with 11.13.0 may not work as expected.`);
4160
4164
  }
4161
4165
  }
4162
4166
  else if (isMotionValue(prevValue)) {
@@ -6180,10 +6184,12 @@ exports.frameSteps = frameSteps;
6180
6184
  exports.inView = inView;
6181
6185
  exports.inertia = inertia;
6182
6186
  exports.interpolate = interpolate;
6187
+ exports.isDragActive = isDragActive;
6183
6188
  exports.keyframes = keyframes;
6184
6189
  exports.mirrorEasing = mirrorEasing;
6185
6190
  exports.mix = mix;
6186
6191
  exports.motionValue = motionValue;
6192
+ exports.noop = noop;
6187
6193
  exports.pipe = pipe;
6188
6194
  exports.progress = progress;
6189
6195
  exports.reverseEasing = reverseEasing;
package/dist/cjs/mini.js CHANGED
@@ -91,6 +91,27 @@ class GroupPlaybackControls {
91
91
  }
92
92
  }
93
93
 
94
+ function resolveElements(elementOrSelector, scope, selectorCache) {
95
+ var _a;
96
+ if (elementOrSelector instanceof Element) {
97
+ return [elementOrSelector];
98
+ }
99
+ else if (typeof elementOrSelector === "string") {
100
+ let root = document;
101
+ if (scope) {
102
+ // TODO: Refactor to utils package
103
+ // invariant(
104
+ // Boolean(scope.current),
105
+ // "Scope provided, but no element detected."
106
+ // )
107
+ root = scope.current;
108
+ }
109
+ const elements = (_a = selectorCache === null || selectorCache === void 0 ? void 0 : selectorCache[elementOrSelector]) !== null && _a !== void 0 ? _a : root.querySelectorAll(elementOrSelector);
110
+ return elements ? Array.from(elements) : [];
111
+ }
112
+ return Array.from(elementOrSelector);
113
+ }
114
+
94
115
  const noop = (any) => any;
95
116
 
96
117
  let invariant = noop;
@@ -102,31 +123,6 @@ if (process.env.NODE_ENV !== "production") {
102
123
  };
103
124
  }
104
125
 
105
- function resolveElements(elements, scope, selectorCache) {
106
- var _a;
107
- if (typeof elements === "string") {
108
- let root = document;
109
- if (scope) {
110
- invariant(Boolean(scope.current), "Scope provided, but no element detected.");
111
- root = scope.current;
112
- }
113
- if (selectorCache) {
114
- (_a = selectorCache[elements]) !== null && _a !== void 0 ? _a : (selectorCache[elements] = root.querySelectorAll(elements));
115
- elements = selectorCache[elements];
116
- }
117
- else {
118
- elements = root.querySelectorAll(elements);
119
- }
120
- }
121
- else if (elements instanceof Element) {
122
- elements = [elements];
123
- }
124
- /**
125
- * Return an empty array
126
- */
127
- return Array.from(elements || []);
128
- }
129
-
130
126
  /**
131
127
  * Converts seconds to milliseconds
132
128
  *
@@ -185,6 +185,21 @@ function getFinalKeyframe(keyframes, { repeat, repeatType = "loop" }, finalKeyfr
185
185
 
186
186
  const noop = (any) => any;
187
187
 
188
+ let warning = noop;
189
+ let invariant = noop;
190
+ if (process.env.NODE_ENV !== "production") {
191
+ warning = (check, message) => {
192
+ if (!check && typeof console !== "undefined") {
193
+ console.warn(message);
194
+ }
195
+ };
196
+ invariant = (check, message) => {
197
+ if (!check) {
198
+ throw new Error(message);
199
+ }
200
+ };
201
+ }
202
+
188
203
  function createRenderStep(runNextFrame) {
189
204
  /**
190
205
  * We create and reuse two queues, one to queue jobs for the current frame
@@ -417,21 +432,6 @@ function isNone(value) {
417
432
  }
418
433
  }
419
434
 
420
- let warning = noop;
421
- let invariant = noop;
422
- if (process.env.NODE_ENV !== "production") {
423
- warning = (check, message) => {
424
- if (!check && typeof console !== "undefined") {
425
- console.warn(message);
426
- }
427
- };
428
- invariant = (check, message) => {
429
- if (!check) {
430
- throw new Error(message);
431
- }
432
- };
433
- }
434
-
435
435
  /**
436
436
  * Check if value is a numerical string, ie a string that is purely a number eg "100" or "-100.1"
437
437
  */
@@ -3348,7 +3348,7 @@ class MotionValue {
3348
3348
  * This will be replaced by the build step with the latest version number.
3349
3349
  * When MotionValues are provided to motion components, warn if versions are mixed.
3350
3350
  */
3351
- this.version = "11.12.0";
3351
+ this.version = "11.13.0";
3352
3352
  /**
3353
3353
  * Tracks whether this value can output a velocity. Currently this is only true
3354
3354
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -4254,6 +4254,102 @@ const animations = {
4254
4254
  },
4255
4255
  };
4256
4256
 
4257
+ function resolveElements(elementOrSelector, scope, selectorCache) {
4258
+ var _a;
4259
+ if (elementOrSelector instanceof Element) {
4260
+ return [elementOrSelector];
4261
+ }
4262
+ else if (typeof elementOrSelector === "string") {
4263
+ let root = document;
4264
+ if (scope) {
4265
+ // TODO: Refactor to utils package
4266
+ // invariant(
4267
+ // Boolean(scope.current),
4268
+ // "Scope provided, but no element detected."
4269
+ // )
4270
+ root = scope.current;
4271
+ }
4272
+ const elements = (_a = selectorCache === null || selectorCache === void 0 ? void 0 : selectorCache[elementOrSelector]) !== null && _a !== void 0 ? _a : root.querySelectorAll(elementOrSelector);
4273
+ return elements ? Array.from(elements) : [];
4274
+ }
4275
+ return Array.from(elementOrSelector);
4276
+ }
4277
+
4278
+ const isDragging = {
4279
+ x: false,
4280
+ y: false,
4281
+ };
4282
+ function isDragActive() {
4283
+ return isDragging.x || isDragging.y;
4284
+ }
4285
+
4286
+ /**
4287
+ * Filter out events that are not pointer events, or are triggering
4288
+ * while a Motion gesture is active.
4289
+ */
4290
+ function filterEvents(callback) {
4291
+ return (event) => {
4292
+ if (event.pointerType === "touch" || isDragActive())
4293
+ return;
4294
+ callback(event);
4295
+ };
4296
+ }
4297
+ /**
4298
+ * Create a hover gesture. hover() is different to .addEventListener("pointerenter")
4299
+ * in that it has an easier syntax, filters out polyfilled touch events, interoperates
4300
+ * with drag gestures, and automatically removes the "pointerennd" event listener when the hover ends.
4301
+ *
4302
+ * @public
4303
+ */
4304
+ function hover(elementOrSelector, onHoverStart, options = {}) {
4305
+ const gestureAbortController = new AbortController();
4306
+ const eventOptions = {
4307
+ passive: true,
4308
+ ...options,
4309
+ signal: gestureAbortController.signal,
4310
+ };
4311
+ const onPointerEnter = filterEvents((enterEvent) => {
4312
+ const { target } = enterEvent;
4313
+ const onHoverEnd = onHoverStart(enterEvent);
4314
+ if (!onHoverEnd || !target)
4315
+ return;
4316
+ const onPointerLeave = filterEvents((leaveEvent) => {
4317
+ onHoverEnd(leaveEvent);
4318
+ target.removeEventListener("pointerleave", onPointerLeave);
4319
+ });
4320
+ target.addEventListener("pointerleave", onPointerLeave, eventOptions);
4321
+ });
4322
+ resolveElements(elementOrSelector).forEach((element) => {
4323
+ element.addEventListener("pointerenter", onPointerEnter, eventOptions);
4324
+ });
4325
+ return () => gestureAbortController.abort();
4326
+ }
4327
+
4328
+ function setDragLock(axis) {
4329
+ if (axis === "x" || axis === "y") {
4330
+ if (isDragging[axis]) {
4331
+ return null;
4332
+ }
4333
+ else {
4334
+ isDragging[axis] = true;
4335
+ return () => {
4336
+ isDragging[axis] = false;
4337
+ };
4338
+ }
4339
+ }
4340
+ else {
4341
+ if (isDragging.x || isDragging.y) {
4342
+ return null;
4343
+ }
4344
+ else {
4345
+ isDragging.x = isDragging.y = true;
4346
+ return () => {
4347
+ isDragging.x = isDragging.y = false;
4348
+ };
4349
+ }
4350
+ }
4351
+ }
4352
+
4257
4353
  const isPrimaryPointer = (event) => {
4258
4354
  if (event.pointerType === "mouse") {
4259
4355
  return typeof event.button !== "number" || event.button <= 0;
@@ -4271,11 +4367,11 @@ const isPrimaryPointer = (event) => {
4271
4367
  }
4272
4368
  };
4273
4369
 
4274
- function extractEventInfo(event, pointType = "page") {
4370
+ function extractEventInfo(event) {
4275
4371
  return {
4276
4372
  point: {
4277
- x: event[`${pointType}X`],
4278
- y: event[`${pointType}Y`],
4373
+ x: event.pageX,
4374
+ y: event.pageY,
4279
4375
  },
4280
4376
  };
4281
4377
  }
@@ -4447,58 +4543,6 @@ function getVelocity(history, timeDelta) {
4447
4543
  return currentVelocity;
4448
4544
  }
4449
4545
 
4450
- function createLock(name) {
4451
- let lock = null;
4452
- return () => {
4453
- const openLock = () => {
4454
- lock = null;
4455
- };
4456
- if (lock === null) {
4457
- lock = name;
4458
- return openLock;
4459
- }
4460
- return false;
4461
- };
4462
- }
4463
- const globalHorizontalLock = createLock("dragHorizontal");
4464
- const globalVerticalLock = createLock("dragVertical");
4465
- function getGlobalLock(drag) {
4466
- let lock = false;
4467
- if (drag === "y") {
4468
- lock = globalVerticalLock();
4469
- }
4470
- else if (drag === "x") {
4471
- lock = globalHorizontalLock();
4472
- }
4473
- else {
4474
- const openHorizontal = globalHorizontalLock();
4475
- const openVertical = globalVerticalLock();
4476
- if (openHorizontal && openVertical) {
4477
- lock = () => {
4478
- openHorizontal();
4479
- openVertical();
4480
- };
4481
- }
4482
- else {
4483
- // Release the locks because we don't use them
4484
- if (openHorizontal)
4485
- openHorizontal();
4486
- if (openVertical)
4487
- openVertical();
4488
- }
4489
- }
4490
- return lock;
4491
- }
4492
- function isDragActive() {
4493
- // Check the gesture lock - if we get it, it means no drag gesture is active
4494
- // and we can safely fire the tap gesture.
4495
- const openGestureLock = getGlobalLock(true);
4496
- if (!openGestureLock)
4497
- return true;
4498
- openGestureLock();
4499
- return false;
4500
- }
4501
-
4502
4546
  function isRefObject(ref) {
4503
4547
  return (ref &&
4504
4548
  typeof ref === "object" &&
@@ -4894,10 +4938,7 @@ const elementDragControls = new WeakMap();
4894
4938
  // let latestPointerEvent: PointerEvent
4895
4939
  class VisualElementDragControls {
4896
4940
  constructor(visualElement) {
4897
- // This is a reference to the global drag gesture lock, ensuring only one component
4898
- // can "capture" the drag of one or both axes.
4899
- // TODO: Look into moving this into pansession?
4900
- this.openGlobalLock = null;
4941
+ this.openDragLock = null;
4901
4942
  this.isDragging = false;
4902
4943
  this.currentDirection = null;
4903
4944
  this.originPoint = { x: 0, y: 0 };
@@ -4925,18 +4966,18 @@ class VisualElementDragControls {
4925
4966
  // the component.
4926
4967
  dragSnapToOrigin ? this.pauseAnimation() : this.stopAnimation();
4927
4968
  if (snapToCursor) {
4928
- this.snapToCursor(extractEventInfo(event, "page").point);
4969
+ this.snapToCursor(extractEventInfo(event).point);
4929
4970
  }
4930
4971
  };
4931
4972
  const onStart = (event, info) => {
4932
4973
  // Attempt to grab the global drag gesture lock - maybe make this part of PanSession
4933
4974
  const { drag, dragPropagation, onDragStart } = this.getProps();
4934
4975
  if (drag && !dragPropagation) {
4935
- if (this.openGlobalLock)
4936
- this.openGlobalLock();
4937
- this.openGlobalLock = getGlobalLock(drag);
4976
+ if (this.openDragLock)
4977
+ this.openDragLock();
4978
+ this.openDragLock = setDragLock(drag);
4938
4979
  // If we don 't have the lock, don't start dragging
4939
- if (!this.openGlobalLock)
4980
+ if (!this.openDragLock)
4940
4981
  return;
4941
4982
  }
4942
4983
  this.isDragging = true;
@@ -4978,7 +5019,7 @@ class VisualElementDragControls {
4978
5019
  // latestPointerEvent = event
4979
5020
  const { dragPropagation, dragDirectionLock, onDirectionLock, onDrag, } = this.getProps();
4980
5021
  // If we didn't successfully receive the gesture lock, early return.
4981
- if (!dragPropagation && !this.openGlobalLock)
5022
+ if (!dragPropagation && !this.openDragLock)
4982
5023
  return;
4983
5024
  const { offset } = info;
4984
5025
  // Attempt to detect drag direction if directionLock is true
@@ -5046,9 +5087,9 @@ class VisualElementDragControls {
5046
5087
  this.panSession && this.panSession.end();
5047
5088
  this.panSession = undefined;
5048
5089
  const { dragPropagation } = this.getProps();
5049
- if (!dragPropagation && this.openGlobalLock) {
5050
- this.openGlobalLock();
5051
- this.openGlobalLock = null;
5090
+ if (!dragPropagation && this.openDragLock) {
5091
+ this.openDragLock();
5092
+ this.openDragLock = null;
5052
5093
  }
5053
5094
  animationState && animationState.setActive("whileDrag", false);
5054
5095
  }
@@ -7686,28 +7727,25 @@ const drag = {
7686
7727
  },
7687
7728
  };
7688
7729
 
7689
- function addHoverEvent(node, isActive) {
7690
- const eventName = isActive ? "pointerenter" : "pointerleave";
7691
- const callbackName = isActive ? "onHoverStart" : "onHoverEnd";
7692
- const handleEvent = (event, info) => {
7693
- if (event.pointerType === "touch" || isDragActive())
7694
- return;
7695
- const props = node.getProps();
7696
- if (node.animationState && props.whileHover) {
7697
- node.animationState.setActive("whileHover", isActive);
7698
- }
7699
- const callback = props[callbackName];
7700
- if (callback) {
7701
- frame.postRender(() => callback(event, info));
7702
- }
7703
- };
7704
- return addPointerEvent(node.current, eventName, handleEvent, {
7705
- passive: !node.getProps()[callbackName],
7706
- });
7730
+ function handleHoverEvent(node, event, isActive) {
7731
+ const { props } = node;
7732
+ if (node.animationState && props.whileHover) {
7733
+ node.animationState.setActive("whileHover", isActive);
7734
+ }
7735
+ const callback = props[isActive ? "onHoverStart" : "onHoverEnd"];
7736
+ if (callback) {
7737
+ frame.postRender(() => callback(event, extractEventInfo(event)));
7738
+ }
7707
7739
  }
7708
7740
  class HoverGesture extends Feature {
7709
7741
  mount() {
7710
- this.unmount = pipe(addHoverEvent(this.node, true), addHoverEvent(this.node, false));
7742
+ const { current, props } = this.node;
7743
+ if (!current)
7744
+ return;
7745
+ this.unmount = hover(current, (startEvent) => {
7746
+ handleHoverEvent(this.node, startEvent, true);
7747
+ return (endEvent) => handleHoverEvent(this.node, endEvent, false);
7748
+ }, { passive: !props.onHoverStart && !props.onHoverEnd });
7711
7749
  }
7712
7750
  unmount() { }
7713
7751
  }
@@ -9091,7 +9129,7 @@ function updateMotionValuesFromProps(element, next, prev) {
9091
9129
  * and warn against mismatches.
9092
9130
  */
9093
9131
  if (process.env.NODE_ENV === "development") {
9094
- warnOnce(nextValue.version === "11.12.0", `Attempting to mix Motion versions ${nextValue.version} with 11.12.0 may not work as expected.`);
9132
+ warnOnce(nextValue.version === "11.13.0", `Attempting to mix Motion versions ${nextValue.version} with 11.13.0 may not work as expected.`);
9095
9133
  }
9096
9134
  }
9097
9135
  else if (isMotionValue(prevValue)) {