framer-motion 7.1.1 → 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.
package/dist/cjs/index.js CHANGED
@@ -2376,7 +2376,7 @@ class MotionValue {
2376
2376
  * This will be replaced by the build step with the latest version number.
2377
2377
  * When MotionValues are provided to motion components, warn if versions are mixed.
2378
2378
  */
2379
- this.version = "7.1.1";
2379
+ this.version = "7.1.2";
2380
2380
  /**
2381
2381
  * Duration, in milliseconds, since last updating frame.
2382
2382
  *
@@ -4282,7 +4282,7 @@ function updateMotionValuesFromProps(element, next, prev) {
4282
4282
  * and warn against mismatches.
4283
4283
  */
4284
4284
  if (process.env.NODE_ENV === "development") {
4285
- warnOnce(nextValue.version === "7.1.1", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.1.1 may not work as expected.`);
4285
+ warnOnce(nextValue.version === "7.1.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.1.2 may not work as expected.`);
4286
4286
  }
4287
4287
  }
4288
4288
  else if (isMotionValue(prevValue)) {
@@ -7691,6 +7691,48 @@ function useTime() {
7691
7691
  return time;
7692
7692
  }
7693
7693
 
7694
+ class WillChangeMotionValue extends MotionValue {
7695
+ constructor() {
7696
+ super(...arguments);
7697
+ this.members = [];
7698
+ this.transforms = new Set();
7699
+ }
7700
+ add(name) {
7701
+ let memberName;
7702
+ if (isTransformProp(name)) {
7703
+ this.transforms.add(name);
7704
+ memberName = "transform";
7705
+ }
7706
+ else if (!isTransformOriginProp(name) &&
7707
+ !isCSSVariable$1(name) &&
7708
+ name !== "willChange") {
7709
+ memberName = camelToDash(name);
7710
+ }
7711
+ if (memberName) {
7712
+ addUniqueItem(this.members, memberName);
7713
+ this.update();
7714
+ }
7715
+ }
7716
+ remove(name) {
7717
+ if (isTransformProp(name)) {
7718
+ this.transforms.delete(name);
7719
+ if (!this.transforms.size) {
7720
+ removeItem(this.members, "transform");
7721
+ }
7722
+ }
7723
+ else {
7724
+ removeItem(this.members, camelToDash(name));
7725
+ }
7726
+ this.update();
7727
+ }
7728
+ update() {
7729
+ this.set(this.members.length ? this.members.join(", ") : "auto");
7730
+ }
7731
+ }
7732
+ function useWillChange() {
7733
+ return useConstant(() => new WillChangeMotionValue("auto"));
7734
+ }
7735
+
7694
7736
  /**
7695
7737
  * @public
7696
7738
  */
@@ -8147,5 +8189,6 @@ exports.useUnmountEffect = useUnmountEffect;
8147
8189
  exports.useVelocity = useVelocity;
8148
8190
  exports.useViewportScroll = useViewportScroll;
8149
8191
  exports.useVisualElementContext = useVisualElementContext;
8192
+ exports.useWillChange = useWillChange;
8150
8193
  exports.visualElement = visualElement;
8151
8194
  exports.wrapHandler = wrapHandler;
package/dist/es/index.mjs CHANGED
@@ -19,6 +19,7 @@ export { useScroll } from './value/use-scroll.mjs';
19
19
  export { useElementScroll } from './value/scroll/use-element-scroll.mjs';
20
20
  export { useViewportScroll } from './value/scroll/use-viewport-scroll.mjs';
21
21
  export { useTime } from './value/use-time.mjs';
22
+ export { useWillChange } from './value/use-will-change/index.mjs';
22
23
  export { useReducedMotion, useReducedMotionConfig } from './utils/use-reduced-motion.mjs';
23
24
  export { animationControls } from './animation/animation-controls.mjs';
24
25
  export { useAnimation, useAnimationControls } from './animation/use-animation.mjs';
@@ -23,7 +23,7 @@ function updateMotionValuesFromProps(element, next, prev) {
23
23
  * and warn against mismatches.
24
24
  */
25
25
  if (process.env.NODE_ENV === "development") {
26
- warnOnce(nextValue.version === "7.1.1", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.1.1 may not work as expected.`);
26
+ warnOnce(nextValue.version === "7.1.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.1.2 may not work as expected.`);
27
27
  }
28
28
  }
29
29
  else if (isMotionValue(prevValue)) {
@@ -24,7 +24,7 @@ class MotionValue {
24
24
  * This will be replaced by the build step with the latest version number.
25
25
  * When MotionValues are provided to motion components, warn if versions are mixed.
26
26
  */
27
- this.version = "7.1.1";
27
+ this.version = "7.1.2";
28
28
  /**
29
29
  * Duration, in milliseconds, since last updating frame.
30
30
  *
@@ -0,0 +1,50 @@
1
+ import { isCSSVariable } from '../../render/dom/utils/is-css-variable.mjs';
2
+ import { isTransformProp, isTransformOriginProp } from '../../render/html/utils/transform.mjs';
3
+ import { addUniqueItem, removeItem } from '../../utils/array.mjs';
4
+ import { useConstant } from '../../utils/use-constant.mjs';
5
+ import { MotionValue } from '../index.mjs';
6
+ import { camelToDash } from '../../render/dom/utils/camel-to-dash.mjs';
7
+
8
+ class WillChangeMotionValue extends MotionValue {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.members = [];
12
+ this.transforms = new Set();
13
+ }
14
+ add(name) {
15
+ let memberName;
16
+ if (isTransformProp(name)) {
17
+ this.transforms.add(name);
18
+ memberName = "transform";
19
+ }
20
+ else if (!isTransformOriginProp(name) &&
21
+ !isCSSVariable(name) &&
22
+ name !== "willChange") {
23
+ memberName = camelToDash(name);
24
+ }
25
+ if (memberName) {
26
+ addUniqueItem(this.members, memberName);
27
+ this.update();
28
+ }
29
+ }
30
+ remove(name) {
31
+ if (isTransformProp(name)) {
32
+ this.transforms.delete(name);
33
+ if (!this.transforms.size) {
34
+ removeItem(this.members, "transform");
35
+ }
36
+ }
37
+ else {
38
+ removeItem(this.members, camelToDash(name));
39
+ }
40
+ this.update();
41
+ }
42
+ update() {
43
+ this.set(this.members.length ? this.members.join(", ") : "auto");
44
+ }
45
+ }
46
+ function useWillChange() {
47
+ return useConstant(() => new WillChangeMotionValue("auto"));
48
+ }
49
+
50
+ export { WillChangeMotionValue, useWillChange };
@@ -3543,7 +3543,7 @@
3543
3543
  * This will be replaced by the build step with the latest version number.
3544
3544
  * When MotionValues are provided to motion components, warn if versions are mixed.
3545
3545
  */
3546
- this.version = "7.1.1";
3546
+ this.version = "7.1.2";
3547
3547
  /**
3548
3548
  * Duration, in milliseconds, since last updating frame.
3549
3549
  *
@@ -5449,7 +5449,7 @@
5449
5449
  * and warn against mismatches.
5450
5450
  */
5451
5451
  {
5452
- warnOnce(nextValue.version === "7.1.1", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.1.1 may not work as expected.`);
5452
+ warnOnce(nextValue.version === "7.1.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.1.2 may not work as expected.`);
5453
5453
  }
5454
5454
  }
5455
5455
  else if (isMotionValue(prevValue)) {
@@ -9439,6 +9439,48 @@
9439
9439
  return time;
9440
9440
  }
9441
9441
 
9442
+ class WillChangeMotionValue extends MotionValue {
9443
+ constructor() {
9444
+ super(...arguments);
9445
+ this.members = [];
9446
+ this.transforms = new Set();
9447
+ }
9448
+ add(name) {
9449
+ let memberName;
9450
+ if (isTransformProp(name)) {
9451
+ this.transforms.add(name);
9452
+ memberName = "transform";
9453
+ }
9454
+ else if (!isTransformOriginProp(name) &&
9455
+ !isCSSVariable$1(name) &&
9456
+ name !== "willChange") {
9457
+ memberName = camelToDash(name);
9458
+ }
9459
+ if (memberName) {
9460
+ addUniqueItem(this.members, memberName);
9461
+ this.update();
9462
+ }
9463
+ }
9464
+ remove(name) {
9465
+ if (isTransformProp(name)) {
9466
+ this.transforms.delete(name);
9467
+ if (!this.transforms.size) {
9468
+ removeItem(this.members, "transform");
9469
+ }
9470
+ }
9471
+ else {
9472
+ removeItem(this.members, camelToDash(name));
9473
+ }
9474
+ this.update();
9475
+ }
9476
+ update() {
9477
+ this.set(this.members.length ? this.members.join(", ") : "auto");
9478
+ }
9479
+ }
9480
+ function useWillChange() {
9481
+ return useConstant(() => new WillChangeMotionValue("auto"));
9482
+ }
9483
+
9442
9484
  /**
9443
9485
  * @public
9444
9486
  */
@@ -9895,6 +9937,7 @@
9895
9937
  exports.useVelocity = useVelocity;
9896
9938
  exports.useViewportScroll = useViewportScroll;
9897
9939
  exports.useVisualElementContext = useVisualElementContext;
9940
+ exports.useWillChange = useWillChange;
9898
9941
  exports.visualElement = visualElement;
9899
9942
  exports.wrapHandler = wrapHandler;
9900
9943