framer-motion 12.23.27 → 12.23.28

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.
@@ -119,7 +119,8 @@
119
119
 
120
120
  exports.warning = () => { };
121
121
  exports.invariant = () => { };
122
- {
122
+ if (typeof process !== "undefined" &&
123
+ process.env?.NODE_ENV !== "production") {
123
124
  exports.warning = (check, message, errorCode) => {
124
125
  if (!check && typeof console !== "undefined") {
125
126
  console.warn(formatErrorMessage(message, errorCode));
@@ -605,6 +606,17 @@
605
606
  return singleCssVariableRegex.test(value.split("/*")[0].trim());
606
607
  };
607
608
  const singleCssVariableRegex = /var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;
609
+ /**
610
+ * Check if a value contains a CSS variable anywhere (e.g. inside calc()).
611
+ * Unlike isCSSVariableToken which checks if the value IS a var() token,
612
+ * this checks if the value CONTAINS var() somewhere in the string.
613
+ */
614
+ function containsCSSVariable(value) {
615
+ if (typeof value !== "string")
616
+ return false;
617
+ // Strip comments to avoid false positives
618
+ return value.split("/*")[0].includes("var(--");
619
+ }
608
620
 
609
621
  const number = {
610
622
  test: (v) => typeof v === "number",
@@ -2608,7 +2620,7 @@
2608
2620
  /**
2609
2621
  * WAAPI doesn't natively have any interruption capabilities.
2610
2622
  *
2611
- * Rather than read commited styles back out of the DOM, we can
2623
+ * Rather than read committed styles back out of the DOM, we can
2612
2624
  * create a renderless JS animation and sample it twice to calculate
2613
2625
  * its current value, "previous" value, and therefore allow
2614
2626
  * Motion to calculate velocity for any subsequent animation.
@@ -2804,7 +2816,7 @@
2804
2816
  * progress, which would feel snappier.
2805
2817
  *
2806
2818
  * However, if there's a delay (main thread work) between the creation of
2807
- * the animation and the first commited frame, we prefer to use resolvedAt
2819
+ * the animation and the first committed frame, we prefer to use resolvedAt
2808
2820
  * to avoid a sudden jump into the animation.
2809
2821
  */
2810
2822
  const startTime = sync
@@ -3306,6 +3318,16 @@
3306
3318
  const [origin, target] = unresolvedKeyframes;
3307
3319
  const originType = findDimensionValueType(origin);
3308
3320
  const targetType = findDimensionValueType(target);
3321
+ /**
3322
+ * If one keyframe contains embedded CSS variables (e.g. in calc()) and the other
3323
+ * doesn't, we need to measure to convert to pixels. This handles GitHub issue #3410.
3324
+ */
3325
+ const originHasVar = containsCSSVariable(origin);
3326
+ const targetHasVar = containsCSSVariable(target);
3327
+ if (originHasVar !== targetHasVar && positionalValues[name]) {
3328
+ this.needsMeasurement = true;
3329
+ return;
3330
+ }
3309
3331
  /**
3310
3332
  * Either we don't recognise these value types or we can animate between them.
3311
3333
  */
@@ -5981,7 +6003,7 @@
5981
6003
  });
5982
6004
  }
5983
6005
  if (delta) {
5984
- // Incoporate each ancestor's scale into a culmulative treeScale for this component
6006
+ // Incoporate each ancestor's scale into a cumulative treeScale for this component
5985
6007
  treeScale.x *= delta.x.scale;
5986
6008
  treeScale.y *= delta.y.scale;
5987
6009
  // Apply each ancestor's calculated delta into this component's recorded layout box
@@ -6707,7 +6729,7 @@
6707
6729
  /**
6708
6730
  * If the layout hasn't changed and we have an animation that hasn't started yet,
6709
6731
  * finish it immediately. Otherwise it will be animating from a location
6710
- * that was probably never commited to screen and look like a jumpy box.
6732
+ * that was probably never committed to screen and look like a jumpy box.
6711
6733
  */
6712
6734
  if (!hasLayoutChanged) {
6713
6735
  finishAnimation(this);
@@ -14220,6 +14242,7 @@
14220
14242
  exports.collectMotionValues = collectMotionValues;
14221
14243
  exports.color = color;
14222
14244
  exports.complex = complex;
14245
+ exports.containsCSSVariable = containsCSSVariable;
14223
14246
  exports.convertOffsetToTimes = convertOffsetToTimes;
14224
14247
  exports.createBox = createBox;
14225
14248
  exports.createGeneratorEasing = createGeneratorEasing;