framer-motion 10.12.18 → 10.12.21

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var indexLegacy = require('./index-legacy-4f1fdbbf.js');
5
+ var indexLegacy = require('./index-legacy-23fa1404.js');
6
6
 
7
7
 
8
8
 
@@ -1796,12 +1796,10 @@ function animateValue({ autoplay = true, delay = 0, driver = frameloopDriver, ke
1796
1796
  let resolveFinishedPromise;
1797
1797
  let currentFinishedPromise;
1798
1798
  /**
1799
- * Create a new finished Promise every time we enter the
1800
- * finished state and resolve the old Promise. This is
1801
- * WAAPI-compatible behaviour.
1799
+ * Resolve the current Promise every time we enter the
1800
+ * finished state. This is WAAPI-compatible behaviour.
1802
1801
  */
1803
1802
  const updateFinishedPromise = () => {
1804
- resolveFinishedPromise && resolveFinishedPromise();
1805
1803
  currentFinishedPromise = new Promise((resolve) => {
1806
1804
  resolveFinishedPromise = resolve;
1807
1805
  });
@@ -1969,6 +1967,7 @@ function animateValue({ autoplay = true, delay = 0, driver = frameloopDriver, ke
1969
1967
  const cancel = () => {
1970
1968
  playState = "idle";
1971
1969
  stopAnimationDriver();
1970
+ resolveFinishedPromise();
1972
1971
  updateFinishedPromise();
1973
1972
  startTime = cancelTime = null;
1974
1973
  };
@@ -1976,7 +1975,7 @@ function animateValue({ autoplay = true, delay = 0, driver = frameloopDriver, ke
1976
1975
  playState = "finished";
1977
1976
  onComplete && onComplete();
1978
1977
  stopAnimationDriver();
1979
- updateFinishedPromise();
1978
+ resolveFinishedPromise();
1980
1979
  };
1981
1980
  const play = () => {
1982
1981
  if (hasStopped)
@@ -1991,6 +1990,9 @@ function animateValue({ autoplay = true, delay = 0, driver = frameloopDriver, ke
1991
1990
  else if (!startTime || playState === "finished") {
1992
1991
  startTime = now;
1993
1992
  }
1993
+ if (playState === "finished") {
1994
+ updateFinishedPromise();
1995
+ }
1994
1996
  cancelTime = startTime;
1995
1997
  holdTime = null;
1996
1998
  /**
@@ -2107,9 +2109,8 @@ function createAcceleratedAnimation(value, valueName, { onUpdate, onComplete, ..
2107
2109
  let resolveFinishedPromise;
2108
2110
  let currentFinishedPromise;
2109
2111
  /**
2110
- * Create a new finished Promise every time we enter the
2111
- * finished state and resolve the old Promise. This is
2112
- * WAAPI-compatible behaviour.
2112
+ * Resolve the current Promise every time we enter the
2113
+ * finished state. This is WAAPI-compatible behaviour.
2113
2114
  */
2114
2115
  const updateFinishedPromise = () => {
2115
2116
  currentFinishedPromise = new Promise((resolve) => {
@@ -2653,7 +2654,7 @@ class MotionValue {
2653
2654
  * This will be replaced by the build step with the latest version number.
2654
2655
  * When MotionValues are provided to motion components, warn if versions are mixed.
2655
2656
  */
2656
- this.version = "10.12.18";
2657
+ this.version = "10.12.21";
2657
2658
  /**
2658
2659
  * Duration, in milliseconds, since last updating frame.
2659
2660
  *
@@ -3036,7 +3037,7 @@ function checkTargetForNewValues(visualElement, target, origin) {
3036
3037
  const newValueKeys = Object.keys(target).filter((key) => !visualElement.hasValue(key));
3037
3038
  const numNewValues = newValueKeys.length;
3038
3039
  if (!numNewValues)
3039
- return;
3040
+ return false;
3040
3041
  for (let i = 0; i < numNewValues; i++) {
3041
3042
  const key = newValueKeys[i];
3042
3043
  const targetValue = target[key];
@@ -3077,6 +3078,7 @@ function checkTargetForNewValues(visualElement, target, origin) {
3077
3078
  if (value !== null)
3078
3079
  visualElement.setBaseTarget(key, value);
3079
3080
  }
3081
+ return true;
3080
3082
  }
3081
3083
  function getOriginFromTransition(key, transition) {
3082
3084
  if (!transition)
@@ -3623,6 +3625,9 @@ const positionalValues = {
3623
3625
  x: getTranslateFromMatrix(4, 13),
3624
3626
  y: getTranslateFromMatrix(5, 14),
3625
3627
  };
3628
+ // Alias translate longform names
3629
+ positionalValues.translateX = positionalValues.x;
3630
+ positionalValues.translateY = positionalValues.y;
3626
3631
  const convertChangedValueTypes = (target, visualElement, changedKeys) => {
3627
3632
  const originBbox = visualElement.measureViewportBox();
3628
3633
  const element = visualElement.current;
@@ -3827,7 +3832,7 @@ function updateMotionValuesFromProps(element, next, prev) {
3827
3832
  * and warn against mismatches.
3828
3833
  */
3829
3834
  if (process.env.NODE_ENV === "development") {
3830
- warnOnce(nextValue.version === "10.12.18", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.12.18 may not work as expected.`);
3835
+ warnOnce(nextValue.version === "10.12.21", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.12.21 may not work as expected.`);
3831
3836
  }
3832
3837
  }
3833
3838
  else if (isMotionValue(prevValue)) {
@@ -4294,9 +4299,10 @@ class VisualElement {
4294
4299
  * directly from the instance (which might have performance implications).
4295
4300
  */
4296
4301
  readValue(key) {
4302
+ var _a;
4297
4303
  return this.latestValues[key] !== undefined || !this.current
4298
4304
  ? this.latestValues[key]
4299
- : this.readValueFromInstance(this.current, key, this.options);
4305
+ : (_a = this.getBaseTargetFromProps(this.props, key)) !== null && _a !== void 0 ? _a : this.readValueFromInstance(this.current, key, this.options);
4300
4306
  }
4301
4307
  /**
4302
4308
  * Set the base target to later animate back to. This is currently
@@ -4380,7 +4386,11 @@ class DOMVisualElement extends VisualElement {
4380
4386
  origin = transformValues(origin);
4381
4387
  }
4382
4388
  if (isMounted) {
4383
- checkTargetForNewValues(this, target, origin);
4389
+ const newValues = checkTargetForNewValues(this, target, origin);
4390
+ // If new values have been added, for instance named color values, transform these
4391
+ if (transformValues && newValues) {
4392
+ origin = transformValues(origin);
4393
+ }
4384
4394
  const parsed = parseDomVariant(this, target, origin, transitionEnd);
4385
4395
  transitionEnd = parsed.transitionEnd;
4386
4396
  target = parsed.target;
package/dist/cjs/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
- var indexLegacy = require('./index-legacy-4f1fdbbf.js');
6
+ var indexLegacy = require('./index-legacy-23fa1404.js');
7
7
 
8
8
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
9
 
@@ -342,6 +342,9 @@ declare type VariableTransitions = {
342
342
  [key: `--${string}`]: Transition;
343
343
  };
344
344
  declare type AnimationOptionsWithValueOverrides<V = any> = StyleTransitions & SVGPathTransitions & SVGTransitions & VariableTransitions & ValueAnimationTransition<V>;
345
+ interface DynamicAnimationOptions extends Omit<AnimationOptionsWithValueOverrides, "delay"> {
346
+ delay?: number | DynamicOption<number>;
347
+ }
345
348
  declare type ElementOrSelector = Element | Element[] | NodeListOf<Element> | string;
346
349
  /**
347
350
  * @public
@@ -617,9 +620,6 @@ interface SequenceOptions extends AnimationPlaybackOptions {
617
620
  defaultTransition?: Transition;
618
621
  }
619
622
 
620
- interface DynamicAnimationOptions extends Omit<AnimationOptionsWithValueOverrides, "delay"> {
621
- delay?: number | DynamicOption<number>;
622
- }
623
623
  declare const createScopedAnimate: (scope?: AnimationScope) => {
624
624
  <V>(from: V, to: V | GenericKeyframesTarget<V>, options?: ValueAnimationTransition<V> | undefined): AnimationPlaybackControls;
625
625
  <V_1>(value: MotionValue<V_1>, keyframes: V_1 | GenericKeyframesTarget<V_1>, options?: ValueAnimationTransition<V_1> | undefined): AnimationPlaybackControls;
@@ -27,12 +27,10 @@ function animateValue({ autoplay = true, delay = 0, driver = frameloopDriver, ke
27
27
  let resolveFinishedPromise;
28
28
  let currentFinishedPromise;
29
29
  /**
30
- * Create a new finished Promise every time we enter the
31
- * finished state and resolve the old Promise. This is
32
- * WAAPI-compatible behaviour.
30
+ * Resolve the current Promise every time we enter the
31
+ * finished state. This is WAAPI-compatible behaviour.
33
32
  */
34
33
  const updateFinishedPromise = () => {
35
- resolveFinishedPromise && resolveFinishedPromise();
36
34
  currentFinishedPromise = new Promise((resolve) => {
37
35
  resolveFinishedPromise = resolve;
38
36
  });
@@ -200,6 +198,7 @@ function animateValue({ autoplay = true, delay = 0, driver = frameloopDriver, ke
200
198
  const cancel = () => {
201
199
  playState = "idle";
202
200
  stopAnimationDriver();
201
+ resolveFinishedPromise();
203
202
  updateFinishedPromise();
204
203
  startTime = cancelTime = null;
205
204
  };
@@ -207,7 +206,7 @@ function animateValue({ autoplay = true, delay = 0, driver = frameloopDriver, ke
207
206
  playState = "finished";
208
207
  onComplete && onComplete();
209
208
  stopAnimationDriver();
210
- updateFinishedPromise();
209
+ resolveFinishedPromise();
211
210
  };
212
211
  const play = () => {
213
212
  if (hasStopped)
@@ -222,6 +221,9 @@ function animateValue({ autoplay = true, delay = 0, driver = frameloopDriver, ke
222
221
  else if (!startTime || playState === "finished") {
223
222
  startTime = now;
224
223
  }
224
+ if (playState === "finished") {
225
+ updateFinishedPromise();
226
+ }
225
227
  cancelTime = startTime;
226
228
  holdTime = null;
227
229
  /**
@@ -46,9 +46,8 @@ function createAcceleratedAnimation(value, valueName, { onUpdate, onComplete, ..
46
46
  let resolveFinishedPromise;
47
47
  let currentFinishedPromise;
48
48
  /**
49
- * Create a new finished Promise every time we enter the
50
- * finished state and resolve the old Promise. This is
51
- * WAAPI-compatible behaviour.
49
+ * Resolve the current Promise every time we enter the
50
+ * finished state. This is WAAPI-compatible behaviour.
52
51
  */
53
52
  const updateFinishedPromise = () => {
54
53
  currentFinishedPromise = new Promise((resolve) => {
@@ -447,9 +447,10 @@ class VisualElement {
447
447
  * directly from the instance (which might have performance implications).
448
448
  */
449
449
  readValue(key) {
450
+ var _a;
450
451
  return this.latestValues[key] !== undefined || !this.current
451
452
  ? this.latestValues[key]
452
- : this.readValueFromInstance(this.current, key, this.options);
453
+ : (_a = this.getBaseTargetFromProps(this.props, key)) !== null && _a !== void 0 ? _a : this.readValueFromInstance(this.current, key, this.options);
453
454
  }
454
455
  /**
455
456
  * Set the base target to later animate back to. This is currently
@@ -32,7 +32,11 @@ class DOMVisualElement extends VisualElement {
32
32
  origin = transformValues(origin);
33
33
  }
34
34
  if (isMounted) {
35
- checkTargetForNewValues(this, target, origin);
35
+ const newValues = checkTargetForNewValues(this, target, origin);
36
+ // If new values have been added, for instance named color values, transform these
37
+ if (transformValues && newValues) {
38
+ origin = transformValues(origin);
39
+ }
36
40
  const parsed = parseDomVariant(this, target, origin, transitionEnd);
37
41
  transitionEnd = parsed.transitionEnd;
38
42
  target = parsed.target;
@@ -69,6 +69,9 @@ const positionalValues = {
69
69
  x: getTranslateFromMatrix(4, 13),
70
70
  y: getTranslateFromMatrix(5, 14),
71
71
  };
72
+ // Alias translate longform names
73
+ positionalValues.translateX = positionalValues.x;
74
+ positionalValues.translateY = positionalValues.y;
72
75
  const convertChangedValueTypes = (target, visualElement, changedKeys) => {
73
76
  const originBbox = visualElement.measureViewportBox();
74
77
  const element = visualElement.current;
@@ -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 === "10.12.18", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.12.18 may not work as expected.`);
25
+ warnOnce(nextValue.version === "10.12.21", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.12.21 may not work as expected.`);
26
26
  }
27
27
  }
28
28
  else if (isMotionValue(prevValue)) {
@@ -56,7 +56,7 @@ function checkTargetForNewValues(visualElement, target, origin) {
56
56
  const newValueKeys = Object.keys(target).filter((key) => !visualElement.hasValue(key));
57
57
  const numNewValues = newValueKeys.length;
58
58
  if (!numNewValues)
59
- return;
59
+ return false;
60
60
  for (let i = 0; i < numNewValues; i++) {
61
61
  const key = newValueKeys[i];
62
62
  const targetValue = target[key];
@@ -97,6 +97,7 @@ function checkTargetForNewValues(visualElement, target, origin) {
97
97
  if (value !== null)
98
98
  visualElement.setBaseTarget(key, value);
99
99
  }
100
+ return true;
100
101
  }
101
102
  function getOriginFromTransition(key, transition) {
102
103
  if (!transition)
@@ -26,7 +26,7 @@ class MotionValue {
26
26
  * This will be replaced by the build step with the latest version number.
27
27
  * When MotionValues are provided to motion components, warn if versions are mixed.
28
28
  */
29
- this.version = "10.12.18";
29
+ this.version = "10.12.21";
30
30
  /**
31
31
  * Duration, in milliseconds, since last updating frame.
32
32
  *
@@ -2925,12 +2925,10 @@
2925
2925
  let resolveFinishedPromise;
2926
2926
  let currentFinishedPromise;
2927
2927
  /**
2928
- * Create a new finished Promise every time we enter the
2929
- * finished state and resolve the old Promise. This is
2930
- * WAAPI-compatible behaviour.
2928
+ * Resolve the current Promise every time we enter the
2929
+ * finished state. This is WAAPI-compatible behaviour.
2931
2930
  */
2932
2931
  const updateFinishedPromise = () => {
2933
- resolveFinishedPromise && resolveFinishedPromise();
2934
2932
  currentFinishedPromise = new Promise((resolve) => {
2935
2933
  resolveFinishedPromise = resolve;
2936
2934
  });
@@ -3098,6 +3096,7 @@
3098
3096
  const cancel = () => {
3099
3097
  playState = "idle";
3100
3098
  stopAnimationDriver();
3099
+ resolveFinishedPromise();
3101
3100
  updateFinishedPromise();
3102
3101
  startTime = cancelTime = null;
3103
3102
  };
@@ -3105,7 +3104,7 @@
3105
3104
  playState = "finished";
3106
3105
  onComplete && onComplete();
3107
3106
  stopAnimationDriver();
3108
- updateFinishedPromise();
3107
+ resolveFinishedPromise();
3109
3108
  };
3110
3109
  const play = () => {
3111
3110
  if (hasStopped)
@@ -3120,6 +3119,9 @@
3120
3119
  else if (!startTime || playState === "finished") {
3121
3120
  startTime = now;
3122
3121
  }
3122
+ if (playState === "finished") {
3123
+ updateFinishedPromise();
3124
+ }
3123
3125
  cancelTime = startTime;
3124
3126
  holdTime = null;
3125
3127
  /**
@@ -3236,9 +3238,8 @@
3236
3238
  let resolveFinishedPromise;
3237
3239
  let currentFinishedPromise;
3238
3240
  /**
3239
- * Create a new finished Promise every time we enter the
3240
- * finished state and resolve the old Promise. This is
3241
- * WAAPI-compatible behaviour.
3241
+ * Resolve the current Promise every time we enter the
3242
+ * finished state. This is WAAPI-compatible behaviour.
3242
3243
  */
3243
3244
  const updateFinishedPromise = () => {
3244
3245
  currentFinishedPromise = new Promise((resolve) => {
@@ -3782,7 +3783,7 @@
3782
3783
  * This will be replaced by the build step with the latest version number.
3783
3784
  * When MotionValues are provided to motion components, warn if versions are mixed.
3784
3785
  */
3785
- this.version = "10.12.18";
3786
+ this.version = "10.12.21";
3786
3787
  /**
3787
3788
  * Duration, in milliseconds, since last updating frame.
3788
3789
  *
@@ -4165,7 +4166,7 @@
4165
4166
  const newValueKeys = Object.keys(target).filter((key) => !visualElement.hasValue(key));
4166
4167
  const numNewValues = newValueKeys.length;
4167
4168
  if (!numNewValues)
4168
- return;
4169
+ return false;
4169
4170
  for (let i = 0; i < numNewValues; i++) {
4170
4171
  const key = newValueKeys[i];
4171
4172
  const targetValue = target[key];
@@ -4206,6 +4207,7 @@
4206
4207
  if (value !== null)
4207
4208
  visualElement.setBaseTarget(key, value);
4208
4209
  }
4210
+ return true;
4209
4211
  }
4210
4212
  function getOriginFromTransition(key, transition) {
4211
4213
  if (!transition)
@@ -6375,6 +6377,9 @@
6375
6377
  x: getTranslateFromMatrix(4, 13),
6376
6378
  y: getTranslateFromMatrix(5, 14),
6377
6379
  };
6380
+ // Alias translate longform names
6381
+ positionalValues.translateX = positionalValues.x;
6382
+ positionalValues.translateY = positionalValues.y;
6378
6383
  const convertChangedValueTypes = (target, visualElement, changedKeys) => {
6379
6384
  const originBbox = visualElement.measureViewportBox();
6380
6385
  const element = visualElement.current;
@@ -6579,7 +6584,7 @@
6579
6584
  * and warn against mismatches.
6580
6585
  */
6581
6586
  {
6582
- warnOnce(nextValue.version === "10.12.18", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.12.18 may not work as expected.`);
6587
+ warnOnce(nextValue.version === "10.12.21", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.12.21 may not work as expected.`);
6583
6588
  }
6584
6589
  }
6585
6590
  else if (isMotionValue(prevValue)) {
@@ -7045,9 +7050,10 @@
7045
7050
  * directly from the instance (which might have performance implications).
7046
7051
  */
7047
7052
  readValue(key) {
7053
+ var _a;
7048
7054
  return this.latestValues[key] !== undefined || !this.current
7049
7055
  ? this.latestValues[key]
7050
- : this.readValueFromInstance(this.current, key, this.options);
7056
+ : (_a = this.getBaseTargetFromProps(this.props, key)) !== null && _a !== void 0 ? _a : this.readValueFromInstance(this.current, key, this.options);
7051
7057
  }
7052
7058
  /**
7053
7059
  * Set the base target to later animate back to. This is currently
@@ -7131,7 +7137,11 @@
7131
7137
  origin = transformValues(origin);
7132
7138
  }
7133
7139
  if (isMounted) {
7134
- checkTargetForNewValues(this, target, origin);
7140
+ const newValues = checkTargetForNewValues(this, target, origin);
7141
+ // If new values have been added, for instance named color values, transform these
7142
+ if (transformValues && newValues) {
7143
+ origin = transformValues(origin);
7144
+ }
7135
7145
  const parsed = parseDomVariant(this, target, origin, transitionEnd);
7136
7146
  transitionEnd = parsed.transitionEnd;
7137
7147
  target = parsed.target;