framer-motion 7.3.6 → 7.5.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.
package/dist/cjs/index.js CHANGED
@@ -683,15 +683,17 @@ function buildHTMLStyles(state, latestValues, options, transformTemplate) {
683
683
  style[key] = valueAsType;
684
684
  }
685
685
  }
686
- if (hasTransform || transformTemplate) {
687
- style.transform = buildTransform(state, options, transformIsNone, transformTemplate);
688
- }
689
- else if (!latestValues.transform && style.transform) {
690
- /**
691
- * If we have previously created a transform but currently don't have any,
692
- * reset transform style to none.
693
- */
694
- style.transform = "none";
686
+ if (!latestValues.transform) {
687
+ if (hasTransform || transformTemplate) {
688
+ style.transform = buildTransform(state, options, transformIsNone, transformTemplate);
689
+ }
690
+ else if (style.transform) {
691
+ /**
692
+ * If we have previously created a transform but currently don't have any,
693
+ * reset transform style to none.
694
+ */
695
+ style.transform = "none";
696
+ }
695
697
  }
696
698
  /**
697
699
  * Build a transformOrigin style. Uses the same defaults as the browser for
@@ -784,6 +786,7 @@ const inViewProps = [
784
786
  const validMotionProps = new Set([
785
787
  "initial",
786
788
  "style",
789
+ "values",
787
790
  "variants",
788
791
  "transition",
789
792
  "transformTemplate",
@@ -2242,7 +2245,7 @@ class MotionValue {
2242
2245
  * This will be replaced by the build step with the latest version number.
2243
2246
  * When MotionValues are provided to motion components, warn if versions are mixed.
2244
2247
  */
2245
- this.version = "7.3.6";
2248
+ this.version = "7.5.0";
2246
2249
  /**
2247
2250
  * Duration, in milliseconds, since last updating frame.
2248
2251
  *
@@ -4218,7 +4221,7 @@ function updateMotionValuesFromProps(element, next, prev) {
4218
4221
  * and warn against mismatches.
4219
4222
  */
4220
4223
  if (process.env.NODE_ENV === "development") {
4221
- warnOnce(nextValue.version === "7.3.6", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.3.6 may not work as expected.`);
4224
+ warnOnce(nextValue.version === "7.5.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.5.0 may not work as expected.`);
4222
4225
  }
4223
4226
  }
4224
4227
  else if (isMotionValue(prevValue)) {
@@ -4353,6 +4356,16 @@ const visualElement = ({ treeType = "", build, getBaseTarget, makeTargetAnimatab
4353
4356
  }
4354
4357
  }
4355
4358
  }
4359
+ /**
4360
+ * Update external values with initial values
4361
+ */
4362
+ if (props.values) {
4363
+ for (const key in props.values) {
4364
+ if (latestValues[key] !== undefined) {
4365
+ props.values[key].set(latestValues[key]);
4366
+ }
4367
+ }
4368
+ }
4356
4369
  /**
4357
4370
  * Determine what role this visual element should take in the variant tree.
4358
4371
  */
@@ -4598,6 +4611,9 @@ const visualElement = ({ treeType = "", build, getBaseTarget, makeTargetAnimatab
4598
4611
  * value, we'll create one if none exists.
4599
4612
  */
4600
4613
  getValue(key, defaultValue) {
4614
+ if (props.values && props.values[key]) {
4615
+ return props.values[key];
4616
+ }
4601
4617
  let value = values.get(key);
4602
4618
  if (value === undefined && defaultValue !== undefined) {
4603
4619
  value = motionValue(defaultValue);
@@ -7840,10 +7856,10 @@ function useAnimationFrame(callback) {
7840
7856
  React.useEffect(() => {
7841
7857
  if (isStatic)
7842
7858
  return;
7843
- const provideTimeSinceStart = ({ timestamp }) => {
7859
+ const provideTimeSinceStart = ({ timestamp, delta }) => {
7844
7860
  if (!initialTimestamp.current)
7845
7861
  initialTimestamp.current = timestamp;
7846
- callback(timestamp - initialTimestamp.current);
7862
+ callback(timestamp - initialTimestamp.current, delta);
7847
7863
  };
7848
7864
  sync__default["default"].update(provideTimeSinceStart, true);
7849
7865
  return () => sync.cancelSync.update(provideTimeSinceStart);
@@ -25,6 +25,7 @@ const inViewProps = [
25
25
  const validMotionProps = new Set([
26
26
  "initial",
27
27
  "style",
28
+ "values",
28
29
  "variants",
29
30
  "transition",
30
31
  "transformTemplate",
@@ -51,15 +51,17 @@ function buildHTMLStyles(state, latestValues, options, transformTemplate) {
51
51
  style[key] = valueAsType;
52
52
  }
53
53
  }
54
- if (hasTransform || transformTemplate) {
55
- style.transform = buildTransform(state, options, transformIsNone, transformTemplate);
56
- }
57
- else if (!latestValues.transform && style.transform) {
58
- /**
59
- * If we have previously created a transform but currently don't have any,
60
- * reset transform style to none.
61
- */
62
- style.transform = "none";
54
+ if (!latestValues.transform) {
55
+ if (hasTransform || transformTemplate) {
56
+ style.transform = buildTransform(state, options, transformIsNone, transformTemplate);
57
+ }
58
+ else if (style.transform) {
59
+ /**
60
+ * If we have previously created a transform but currently don't have any,
61
+ * reset transform style to none.
62
+ */
63
+ style.transform = "none";
64
+ }
63
65
  }
64
66
  /**
65
67
  * Build a transformOrigin style. Uses the same defaults as the browser for
@@ -112,6 +112,16 @@ const visualElement = ({ treeType = "", build, getBaseTarget, makeTargetAnimatab
112
112
  }
113
113
  }
114
114
  }
115
+ /**
116
+ * Update external values with initial values
117
+ */
118
+ if (props.values) {
119
+ for (const key in props.values) {
120
+ if (latestValues[key] !== undefined) {
121
+ props.values[key].set(latestValues[key]);
122
+ }
123
+ }
124
+ }
115
125
  /**
116
126
  * Determine what role this visual element should take in the variant tree.
117
127
  */
@@ -357,6 +367,9 @@ const visualElement = ({ treeType = "", build, getBaseTarget, makeTargetAnimatab
357
367
  * value, we'll create one if none exists.
358
368
  */
359
369
  getValue(key, defaultValue) {
370
+ if (props.values && props.values[key]) {
371
+ return props.values[key];
372
+ }
360
373
  let value = values.get(key);
361
374
  if (value === undefined && defaultValue !== undefined) {
362
375
  value = motionValue(defaultValue);
@@ -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 === "7.3.6", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.3.6 may not work as expected.`);
25
+ warnOnce(nextValue.version === "7.5.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.5.0 may not work as expected.`);
26
26
  }
27
27
  }
28
28
  else if (isMotionValue(prevValue)) {
@@ -8,10 +8,10 @@ function useAnimationFrame(callback) {
8
8
  useEffect(() => {
9
9
  if (isStatic)
10
10
  return;
11
- const provideTimeSinceStart = ({ timestamp }) => {
11
+ const provideTimeSinceStart = ({ timestamp, delta }) => {
12
12
  if (!initialTimestamp.current)
13
13
  initialTimestamp.current = timestamp;
14
- callback(timestamp - initialTimestamp.current);
14
+ callback(timestamp - initialTimestamp.current, delta);
15
15
  };
16
16
  sync.update(provideTimeSinceStart, true);
17
17
  return () => cancelSync.update(provideTimeSinceStart);
@@ -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.3.6";
27
+ this.version = "7.5.0";
28
28
  /**
29
29
  * Duration, in milliseconds, since last updating frame.
30
30
  *
@@ -878,15 +878,17 @@
878
878
  style[key] = valueAsType;
879
879
  }
880
880
  }
881
- if (hasTransform || transformTemplate) {
882
- style.transform = buildTransform(state, options, transformIsNone, transformTemplate);
883
- }
884
- else if (!latestValues.transform && style.transform) {
885
- /**
886
- * If we have previously created a transform but currently don't have any,
887
- * reset transform style to none.
888
- */
889
- style.transform = "none";
881
+ if (!latestValues.transform) {
882
+ if (hasTransform || transformTemplate) {
883
+ style.transform = buildTransform(state, options, transformIsNone, transformTemplate);
884
+ }
885
+ else if (style.transform) {
886
+ /**
887
+ * If we have previously created a transform but currently don't have any,
888
+ * reset transform style to none.
889
+ */
890
+ style.transform = "none";
891
+ }
890
892
  }
891
893
  /**
892
894
  * Build a transformOrigin style. Uses the same defaults as the browser for
@@ -979,6 +981,7 @@
979
981
  const validMotionProps = new Set([
980
982
  "initial",
981
983
  "style",
984
+ "values",
982
985
  "variants",
983
986
  "transition",
984
987
  "transformTemplate",
@@ -3410,7 +3413,7 @@
3410
3413
  * This will be replaced by the build step with the latest version number.
3411
3414
  * When MotionValues are provided to motion components, warn if versions are mixed.
3412
3415
  */
3413
- this.version = "7.3.6";
3416
+ this.version = "7.5.0";
3414
3417
  /**
3415
3418
  * Duration, in milliseconds, since last updating frame.
3416
3419
  *
@@ -5386,7 +5389,7 @@
5386
5389
  * and warn against mismatches.
5387
5390
  */
5388
5391
  {
5389
- warnOnce(nextValue.version === "7.3.6", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.3.6 may not work as expected.`);
5392
+ warnOnce(nextValue.version === "7.5.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.5.0 may not work as expected.`);
5390
5393
  }
5391
5394
  }
5392
5395
  else if (isMotionValue(prevValue)) {
@@ -5521,6 +5524,16 @@
5521
5524
  }
5522
5525
  }
5523
5526
  }
5527
+ /**
5528
+ * Update external values with initial values
5529
+ */
5530
+ if (props.values) {
5531
+ for (const key in props.values) {
5532
+ if (latestValues[key] !== undefined) {
5533
+ props.values[key].set(latestValues[key]);
5534
+ }
5535
+ }
5536
+ }
5524
5537
  /**
5525
5538
  * Determine what role this visual element should take in the variant tree.
5526
5539
  */
@@ -5766,6 +5779,9 @@
5766
5779
  * value, we'll create one if none exists.
5767
5780
  */
5768
5781
  getValue(key, defaultValue) {
5782
+ if (props.values && props.values[key]) {
5783
+ return props.values[key];
5784
+ }
5769
5785
  let value = values.get(key);
5770
5786
  if (value === undefined && defaultValue !== undefined) {
5771
5787
  value = motionValue(defaultValue);
@@ -9589,10 +9605,10 @@
9589
9605
  React.useEffect(() => {
9590
9606
  if (isStatic)
9591
9607
  return;
9592
- const provideTimeSinceStart = ({ timestamp }) => {
9608
+ const provideTimeSinceStart = ({ timestamp, delta }) => {
9593
9609
  if (!initialTimestamp.current)
9594
9610
  initialTimestamp.current = timestamp;
9595
- callback(timestamp - initialTimestamp.current);
9611
+ callback(timestamp - initialTimestamp.current, delta);
9596
9612
  };
9597
9613
  sync.update(provideTimeSinceStart, true);
9598
9614
  return () => cancelSync.update(provideTimeSinceStart);