framer-motion 9.1.1 → 9.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.
package/dist/cjs/index.js CHANGED
@@ -150,25 +150,14 @@ function isAnimationControls(v) {
150
150
  return typeof v === "object" && typeof v.start === "function";
151
151
  }
152
152
 
153
- exports.AnimationType = void 0;
154
- (function (AnimationType) {
155
- AnimationType["Animate"] = "animate";
156
- AnimationType["Hover"] = "whileHover";
157
- AnimationType["Tap"] = "whileTap";
158
- AnimationType["Drag"] = "whileDrag";
159
- AnimationType["Focus"] = "whileFocus";
160
- AnimationType["InView"] = "whileInView";
161
- AnimationType["Exit"] = "exit";
162
- })(exports.AnimationType || (exports.AnimationType = {}));
163
-
164
153
  const variantPriorityOrder$1 = [
165
- exports.AnimationType.Animate,
166
- exports.AnimationType.InView,
167
- exports.AnimationType.Focus,
168
- exports.AnimationType.Hover,
169
- exports.AnimationType.Tap,
170
- exports.AnimationType.Drag,
171
- exports.AnimationType.Exit,
154
+ "animate" /* AnimationType.Animate */,
155
+ "whileInView" /* AnimationType.InView */,
156
+ "whileFocus" /* AnimationType.Focus */,
157
+ "whileHover" /* AnimationType.Hover */,
158
+ "whileTap" /* AnimationType.Tap */,
159
+ "whileDrag" /* AnimationType.Drag */,
160
+ "exit" /* AnimationType.Exit */,
172
161
  ];
173
162
  const variantProps = ["initial", ...variantPriorityOrder$1];
174
163
 
@@ -1416,7 +1405,7 @@ function addHoverEvent(node, isActive) {
1416
1405
  return;
1417
1406
  const props = node.getProps();
1418
1407
  if (node.animationState && props.whileHover) {
1419
- node.animationState.setActive(exports.AnimationType.Hover, isActive);
1408
+ node.animationState.setActive("whileHover" /* AnimationType.Hover */, isActive);
1420
1409
  }
1421
1410
  if (props[callbackName]) {
1422
1411
  props[callbackName](event, info);
@@ -1454,13 +1443,13 @@ class FocusGesture extends Feature {
1454
1443
  }
1455
1444
  if (!isFocusVisible || !this.node.animationState)
1456
1445
  return;
1457
- this.node.animationState.setActive(exports.AnimationType.Focus, true);
1446
+ this.node.animationState.setActive("whileFocus" /* AnimationType.Focus */, true);
1458
1447
  this.isActive = true;
1459
1448
  }
1460
1449
  onBlur() {
1461
1450
  if (!this.isActive || !this.node.animationState)
1462
1451
  return;
1463
- this.node.animationState.setActive(exports.AnimationType.Focus, false);
1452
+ this.node.animationState.setActive("whileFocus" /* AnimationType.Focus */, false);
1464
1453
  this.isActive = false;
1465
1454
  }
1466
1455
  mount() {
@@ -1556,7 +1545,7 @@ class PressGesture extends Feature {
1556
1545
  * Ensure we trigger animations before firing event callback
1557
1546
  */
1558
1547
  if (whileTap && this.node.animationState) {
1559
- this.node.animationState.setActive(exports.AnimationType.Tap, true);
1548
+ this.node.animationState.setActive("whileTap" /* AnimationType.Tap */, true);
1560
1549
  }
1561
1550
  onTapStart && onTapStart(event, info);
1562
1551
  }
@@ -1565,7 +1554,7 @@ class PressGesture extends Feature {
1565
1554
  this.isPressing = false;
1566
1555
  const props = this.node.getProps();
1567
1556
  if (props.whileTap && this.node.animationState) {
1568
- this.node.animationState.setActive(exports.AnimationType.Tap, false);
1557
+ this.node.animationState.setActive("whileTap" /* AnimationType.Tap */, false);
1569
1558
  }
1570
1559
  return !isDragActive();
1571
1560
  }
@@ -1660,7 +1649,7 @@ class InViewFeature extends Feature {
1660
1649
  const { onViewportEnter } = this.node.getProps();
1661
1650
  onViewportEnter && onViewportEnter(null);
1662
1651
  if (this.node.animationState) {
1663
- this.node.animationState.setActive(exports.AnimationType.InView, true);
1652
+ this.node.animationState.setActive("whileInView" /* AnimationType.InView */, true);
1664
1653
  }
1665
1654
  });
1666
1655
  }
@@ -1697,7 +1686,7 @@ class InViewFeature extends Feature {
1697
1686
  this.hasEnteredView = true;
1698
1687
  }
1699
1688
  if (this.node.animationState) {
1700
- this.node.animationState.setActive(exports.AnimationType.InView, isIntersecting);
1689
+ this.node.animationState.setActive("whileInView" /* AnimationType.InView */, isIntersecting);
1701
1690
  }
1702
1691
  /**
1703
1692
  * Use the latest committed props rather than the ones in scope
@@ -2011,7 +2000,7 @@ class MotionValue {
2011
2000
  * This will be replaced by the build step with the latest version number.
2012
2001
  * When MotionValues are provided to motion components, warn if versions are mixed.
2013
2002
  */
2014
- this.version = "9.1.1";
2003
+ this.version = "9.1.2";
2015
2004
  /**
2016
2005
  * Duration, in milliseconds, since last updating frame.
2017
2006
  *
@@ -4191,13 +4180,13 @@ function shouldBlockAnimation({ protectedKeys, needsAnimating }, key) {
4191
4180
  }
4192
4181
 
4193
4182
  const variantPriorityOrder = [
4194
- exports.AnimationType.Animate,
4195
- exports.AnimationType.InView,
4196
- exports.AnimationType.Focus,
4197
- exports.AnimationType.Hover,
4198
- exports.AnimationType.Tap,
4199
- exports.AnimationType.Drag,
4200
- exports.AnimationType.Exit,
4183
+ "animate" /* AnimationType.Animate */,
4184
+ "whileInView" /* AnimationType.InView */,
4185
+ "whileFocus" /* AnimationType.Focus */,
4186
+ "whileHover" /* AnimationType.Hover */,
4187
+ "whileTap" /* AnimationType.Tap */,
4188
+ "whileDrag" /* AnimationType.Drag */,
4189
+ "exit" /* AnimationType.Exit */,
4201
4190
  ];
4202
4191
  const reversePriorityOrder = [...variantPriorityOrder].reverse();
4203
4192
  const numAnimationTypes = variantPriorityOrder.length;
@@ -4499,13 +4488,13 @@ function createTypeState(isActive = false) {
4499
4488
  }
4500
4489
  function createState() {
4501
4490
  return {
4502
- [exports.AnimationType.Animate]: createTypeState(true),
4503
- [exports.AnimationType.InView]: createTypeState(),
4504
- [exports.AnimationType.Hover]: createTypeState(),
4505
- [exports.AnimationType.Tap]: createTypeState(),
4506
- [exports.AnimationType.Drag]: createTypeState(),
4507
- [exports.AnimationType.Focus]: createTypeState(),
4508
- [exports.AnimationType.Exit]: createTypeState(),
4491
+ ["animate" /* AnimationType.Animate */]: createTypeState(true),
4492
+ ["whileInView" /* AnimationType.InView */]: createTypeState(),
4493
+ ["whileHover" /* AnimationType.Hover */]: createTypeState(),
4494
+ ["whileTap" /* AnimationType.Tap */]: createTypeState(),
4495
+ ["whileDrag" /* AnimationType.Drag */]: createTypeState(),
4496
+ ["whileFocus" /* AnimationType.Focus */]: createTypeState(),
4497
+ ["exit" /* AnimationType.Exit */]: createTypeState(),
4509
4498
  };
4510
4499
  }
4511
4500
 
@@ -4556,7 +4545,7 @@ class ExitAnimationFeature extends Feature {
4556
4545
  if (!this.node.animationState || isPresent === prevIsPresent) {
4557
4546
  return;
4558
4547
  }
4559
- const exitAnimation = this.node.animationState.setActive(exports.AnimationType.Exit, !isPresent, { custom: custom !== null && custom !== void 0 ? custom : this.node.getProps().custom });
4548
+ const exitAnimation = this.node.animationState.setActive("exit" /* AnimationType.Exit */, !isPresent, { custom: custom !== null && custom !== void 0 ? custom : this.node.getProps().custom });
4560
4549
  if (onExitComplete && !isPresent) {
4561
4550
  exitAnimation.then(() => onExitComplete(this.id));
4562
4551
  }
@@ -5170,7 +5159,7 @@ class VisualElementDragControls {
5170
5159
  // Fire onDragStart event
5171
5160
  onDragStart && onDragStart(event, info);
5172
5161
  const { animationState } = this.visualElement;
5173
- animationState && animationState.setActive(exports.AnimationType.Drag, true);
5162
+ animationState && animationState.setActive("whileDrag" /* AnimationType.Drag */, true);
5174
5163
  };
5175
5164
  const onMove = (event, info) => {
5176
5165
  // latestPointerEvent = event
@@ -5235,7 +5224,7 @@ class VisualElementDragControls {
5235
5224
  this.openGlobalLock();
5236
5225
  this.openGlobalLock = null;
5237
5226
  }
5238
- animationState && animationState.setActive(exports.AnimationType.Drag, false);
5227
+ animationState && animationState.setActive("whileDrag" /* AnimationType.Drag */, false);
5239
5228
  }
5240
5229
  updateAxis(axis, _point, offset) {
5241
5230
  const { drag } = this.getProps();
@@ -7521,15 +7510,6 @@ const hasPositionalKey = (target) => {
7521
7510
  return Object.keys(target).some(isPositionalKey);
7522
7511
  };
7523
7512
  const isNumOrPxType = (v) => v === number || v === px;
7524
- var BoundingBoxDimension;
7525
- (function (BoundingBoxDimension) {
7526
- BoundingBoxDimension["width"] = "width";
7527
- BoundingBoxDimension["height"] = "height";
7528
- BoundingBoxDimension["left"] = "left";
7529
- BoundingBoxDimension["right"] = "right";
7530
- BoundingBoxDimension["top"] = "top";
7531
- BoundingBoxDimension["bottom"] = "bottom";
7532
- })(BoundingBoxDimension || (BoundingBoxDimension = {}));
7533
7513
  const getPosFromMatrix = (matrix, pos) => parseFloat(matrix.split(", ")[pos]);
7534
7514
  const getTranslateFromMatrix = (pos2, pos3) => (_bbox, { transform }) => {
7535
7515
  if (transform === "none" || !transform)
@@ -7784,7 +7764,7 @@ function updateMotionValuesFromProps(element, next, prev) {
7784
7764
  * and warn against mismatches.
7785
7765
  */
7786
7766
  if (process.env.NODE_ENV === "development") {
7787
- warnOnce(nextValue.version === "9.1.1", `Attempting to mix Framer Motion versions ${nextValue.version} with 9.1.1 may not work as expected.`);
7767
+ warnOnce(nextValue.version === "9.1.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 9.1.2 may not work as expected.`);
7788
7768
  }
7789
7769
  }
7790
7770
  else if (isMotionValue(prevValue)) {
@@ -9299,6 +9279,17 @@ const Reorder = {
9299
9279
  Item,
9300
9280
  };
9301
9281
 
9282
+ exports.AnimationType = void 0;
9283
+ (function (AnimationType) {
9284
+ AnimationType["Animate"] = "animate";
9285
+ AnimationType["Hover"] = "whileHover";
9286
+ AnimationType["Tap"] = "whileTap";
9287
+ AnimationType["Drag"] = "whileDrag";
9288
+ AnimationType["Focus"] = "whileFocus";
9289
+ AnimationType["InView"] = "whileInView";
9290
+ AnimationType["Exit"] = "exit";
9291
+ })(exports.AnimationType || (exports.AnimationType = {}));
9292
+
9302
9293
  /**
9303
9294
  * @public
9304
9295
  */
@@ -4,7 +4,6 @@ import { getGlobalLock } from './utils/lock.mjs';
4
4
  import { isRefObject } from '../../utils/is-ref-object.mjs';
5
5
  import { addPointerEvent } from '../../events/add-pointer-event.mjs';
6
6
  import { applyConstraints, calcRelativeConstraints, resolveDragElastic, calcViewportConstraints, defaultElastic, rebaseAxisConstraints, calcOrigin } from './utils/constraints.mjs';
7
- import { AnimationType } from '../../render/utils/types.mjs';
8
7
  import { createBox } from '../../projection/geometry/models.mjs';
9
8
  import { eachAxis } from '../../projection/utils/each-axis.mjs';
10
9
  import { measurePageBox } from '../../projection/utils/measure.mjs';
@@ -97,7 +96,7 @@ class VisualElementDragControls {
97
96
  // Fire onDragStart event
98
97
  onDragStart && onDragStart(event, info);
99
98
  const { animationState } = this.visualElement;
100
- animationState && animationState.setActive(AnimationType.Drag, true);
99
+ animationState && animationState.setActive("whileDrag" /* AnimationType.Drag */, true);
101
100
  };
102
101
  const onMove = (event, info) => {
103
102
  // latestPointerEvent = event
@@ -162,7 +161,7 @@ class VisualElementDragControls {
162
161
  this.openGlobalLock();
163
162
  this.openGlobalLock = null;
164
163
  }
165
- animationState && animationState.setActive(AnimationType.Drag, false);
164
+ animationState && animationState.setActive("whileDrag" /* AnimationType.Drag */, false);
166
165
  }
167
166
  updateAxis(axis, _point, offset) {
168
167
  const { drag } = this.getProps();
@@ -1,6 +1,5 @@
1
1
  import { addDomEvent } from '../events/add-dom-event.mjs';
2
2
  import { Feature } from '../motion/features/Feature.mjs';
3
- import { AnimationType } from '../render/utils/types.mjs';
4
3
  import { pipe } from '../utils/pipe.mjs';
5
4
 
6
5
  class FocusGesture extends Feature {
@@ -24,13 +23,13 @@ class FocusGesture extends Feature {
24
23
  }
25
24
  if (!isFocusVisible || !this.node.animationState)
26
25
  return;
27
- this.node.animationState.setActive(AnimationType.Focus, true);
26
+ this.node.animationState.setActive("whileFocus" /* AnimationType.Focus */, true);
28
27
  this.isActive = true;
29
28
  }
30
29
  onBlur() {
31
30
  if (!this.isActive || !this.node.animationState)
32
31
  return;
33
- this.node.animationState.setActive(AnimationType.Focus, false);
32
+ this.node.animationState.setActive("whileFocus" /* AnimationType.Focus */, false);
34
33
  this.isActive = false;
35
34
  }
36
35
  mount() {
@@ -1,5 +1,4 @@
1
1
  import { addPointerEvent } from '../events/add-pointer-event.mjs';
2
- import { AnimationType } from '../render/utils/types.mjs';
3
2
  import { pipe } from '../utils/pipe.mjs';
4
3
  import { isDragActive } from './drag/utils/lock.mjs';
5
4
  import { Feature } from '../motion/features/Feature.mjs';
@@ -12,7 +11,7 @@ function addHoverEvent(node, isActive) {
12
11
  return;
13
12
  const props = node.getProps();
14
13
  if (node.animationState && props.whileHover) {
15
- node.animationState.setActive(AnimationType.Hover, isActive);
14
+ node.animationState.setActive("whileHover" /* AnimationType.Hover */, isActive);
16
15
  }
17
16
  if (props[callbackName]) {
18
17
  props[callbackName](event, info);
@@ -2,7 +2,6 @@ import { extractEventInfo } from '../events/event-info.mjs';
2
2
  import { addDomEvent } from '../events/add-dom-event.mjs';
3
3
  import { addPointerEvent } from '../events/add-pointer-event.mjs';
4
4
  import { Feature } from '../motion/features/Feature.mjs';
5
- import { AnimationType } from '../render/utils/types.mjs';
6
5
  import { pipe } from '../utils/pipe.mjs';
7
6
  import { isDragActive } from './drag/utils/lock.mjs';
8
7
  import { isNodeOrChild } from './utils/is-node-or-child.mjs';
@@ -74,7 +73,7 @@ class PressGesture extends Feature {
74
73
  * Ensure we trigger animations before firing event callback
75
74
  */
76
75
  if (whileTap && this.node.animationState) {
77
- this.node.animationState.setActive(AnimationType.Tap, true);
76
+ this.node.animationState.setActive("whileTap" /* AnimationType.Tap */, true);
78
77
  }
79
78
  onTapStart && onTapStart(event, info);
80
79
  }
@@ -83,7 +82,7 @@ class PressGesture extends Feature {
83
82
  this.isPressing = false;
84
83
  const props = this.node.getProps();
85
84
  if (props.whileTap && this.node.animationState) {
86
- this.node.animationState.setActive(AnimationType.Tap, false);
85
+ this.node.animationState.setActive("whileTap" /* AnimationType.Tap */, false);
87
86
  }
88
87
  return !isDragActive();
89
88
  }
@@ -1,4 +1,3 @@
1
- import { AnimationType } from '../../../render/utils/types.mjs';
2
1
  import { Feature } from '../Feature.mjs';
3
2
 
4
3
  let id = 0;
@@ -15,7 +14,7 @@ class ExitAnimationFeature extends Feature {
15
14
  if (!this.node.animationState || isPresent === prevIsPresent) {
16
15
  return;
17
16
  }
18
- const exitAnimation = this.node.animationState.setActive(AnimationType.Exit, !isPresent, { custom: custom !== null && custom !== void 0 ? custom : this.node.getProps().custom });
17
+ const exitAnimation = this.node.animationState.setActive("exit" /* AnimationType.Exit */, !isPresent, { custom: custom !== null && custom !== void 0 ? custom : this.node.getProps().custom });
19
18
  if (onExitComplete && !isPresent) {
20
19
  exitAnimation.then(() => onExitComplete(this.id));
21
20
  }
@@ -1,4 +1,3 @@
1
- import { AnimationType } from '../../../render/utils/types.mjs';
2
1
  import { Feature } from '../Feature.mjs';
3
2
  import { observeIntersection } from './observers.mjs';
4
3
 
@@ -26,7 +25,7 @@ class InViewFeature extends Feature {
26
25
  const { onViewportEnter } = this.node.getProps();
27
26
  onViewportEnter && onViewportEnter(null);
28
27
  if (this.node.animationState) {
29
- this.node.animationState.setActive(AnimationType.InView, true);
28
+ this.node.animationState.setActive("whileInView" /* AnimationType.InView */, true);
30
29
  }
31
30
  });
32
31
  }
@@ -63,7 +62,7 @@ class InViewFeature extends Feature {
63
62
  this.hasEnteredView = true;
64
63
  }
65
64
  if (this.node.animationState) {
66
- this.node.animationState.setActive(AnimationType.InView, isIntersecting);
65
+ this.node.animationState.setActive("whileInView" /* AnimationType.InView */, isIntersecting);
67
66
  }
68
67
  /**
69
68
  * Use the latest committed props rather than the ones in scope
@@ -21,15 +21,6 @@ const hasPositionalKey = (target) => {
21
21
  return Object.keys(target).some(isPositionalKey);
22
22
  };
23
23
  const isNumOrPxType = (v) => v === number || v === px;
24
- var BoundingBoxDimension;
25
- (function (BoundingBoxDimension) {
26
- BoundingBoxDimension["width"] = "width";
27
- BoundingBoxDimension["height"] = "height";
28
- BoundingBoxDimension["left"] = "left";
29
- BoundingBoxDimension["right"] = "right";
30
- BoundingBoxDimension["top"] = "top";
31
- BoundingBoxDimension["bottom"] = "bottom";
32
- })(BoundingBoxDimension || (BoundingBoxDimension = {}));
33
24
  const getPosFromMatrix = (matrix, pos) => parseFloat(matrix.split(", ")[pos]);
34
25
  const getTranslateFromMatrix = (pos2, pos3) => (_bbox, { transform }) => {
35
26
  if (transform === "none" || !transform)
@@ -225,4 +216,4 @@ function unitConversion(visualElement, target, origin, transitionEnd) {
225
216
  : { target, transitionEnd };
226
217
  }
227
218
 
228
- export { BoundingBoxDimension, positionalValues, unitConversion };
219
+ export { positionalValues, unitConversion };
@@ -3,17 +3,16 @@ import { isKeyframesTarget } from '../../animation/utils/is-keyframes-target.mjs
3
3
  import { shallowCompare } from '../../utils/shallow-compare.mjs';
4
4
  import { animateVisualElement } from './animation.mjs';
5
5
  import { isVariantLabel } from './is-variant-label.mjs';
6
- import { AnimationType } from './types.mjs';
7
6
  import { resolveVariant } from './resolve-dynamic-variants.mjs';
8
7
 
9
8
  const variantPriorityOrder = [
10
- AnimationType.Animate,
11
- AnimationType.InView,
12
- AnimationType.Focus,
13
- AnimationType.Hover,
14
- AnimationType.Tap,
15
- AnimationType.Drag,
16
- AnimationType.Exit,
9
+ "animate" /* AnimationType.Animate */,
10
+ "whileInView" /* AnimationType.InView */,
11
+ "whileFocus" /* AnimationType.Focus */,
12
+ "whileHover" /* AnimationType.Hover */,
13
+ "whileTap" /* AnimationType.Tap */,
14
+ "whileDrag" /* AnimationType.Drag */,
15
+ "exit" /* AnimationType.Exit */,
17
16
  ];
18
17
  const reversePriorityOrder = [...variantPriorityOrder].reverse();
19
18
  const numAnimationTypes = variantPriorityOrder.length;
@@ -315,13 +314,13 @@ function createTypeState(isActive = false) {
315
314
  }
316
315
  function createState() {
317
316
  return {
318
- [AnimationType.Animate]: createTypeState(true),
319
- [AnimationType.InView]: createTypeState(),
320
- [AnimationType.Hover]: createTypeState(),
321
- [AnimationType.Tap]: createTypeState(),
322
- [AnimationType.Drag]: createTypeState(),
323
- [AnimationType.Focus]: createTypeState(),
324
- [AnimationType.Exit]: createTypeState(),
317
+ ["animate" /* AnimationType.Animate */]: createTypeState(true),
318
+ ["whileInView" /* AnimationType.InView */]: createTypeState(),
319
+ ["whileHover" /* AnimationType.Hover */]: createTypeState(),
320
+ ["whileTap" /* AnimationType.Tap */]: createTypeState(),
321
+ ["whileDrag" /* AnimationType.Drag */]: createTypeState(),
322
+ ["whileFocus" /* AnimationType.Focus */]: createTypeState(),
323
+ ["exit" /* AnimationType.Exit */]: createTypeState(),
325
324
  };
326
325
  }
327
326
 
@@ -22,7 +22,7 @@ function updateMotionValuesFromProps(element, next, prev) {
22
22
  * and warn against mismatches.
23
23
  */
24
24
  if (process.env.NODE_ENV === "development") {
25
- warnOnce(nextValue.version === "9.1.1", `Attempting to mix Framer Motion versions ${nextValue.version} with 9.1.1 may not work as expected.`);
25
+ warnOnce(nextValue.version === "9.1.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 9.1.2 may not work as expected.`);
26
26
  }
27
27
  }
28
28
  else if (isMotionValue(prevValue)) {
@@ -1,13 +1,11 @@
1
- import { AnimationType } from './types.mjs';
2
-
3
1
  const variantPriorityOrder = [
4
- AnimationType.Animate,
5
- AnimationType.InView,
6
- AnimationType.Focus,
7
- AnimationType.Hover,
8
- AnimationType.Tap,
9
- AnimationType.Drag,
10
- AnimationType.Exit,
2
+ "animate" /* AnimationType.Animate */,
3
+ "whileInView" /* AnimationType.InView */,
4
+ "whileFocus" /* AnimationType.Focus */,
5
+ "whileHover" /* AnimationType.Hover */,
6
+ "whileTap" /* AnimationType.Tap */,
7
+ "whileDrag" /* AnimationType.Drag */,
8
+ "exit" /* AnimationType.Exit */,
11
9
  ];
12
10
  const variantProps = ["initial", ...variantPriorityOrder];
13
11
 
@@ -25,7 +25,7 @@ class MotionValue {
25
25
  * This will be replaced by the build step with the latest version number.
26
26
  * When MotionValues are provided to motion components, warn if versions are mixed.
27
27
  */
28
- this.version = "9.1.1";
28
+ this.version = "9.1.2";
29
29
  /**
30
30
  * Duration, in milliseconds, since last updating frame.
31
31
  *