framer-motion 11.0.21 → 11.0.23

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/index.d.ts CHANGED
@@ -1860,6 +1860,7 @@ interface ValueAnimationOptions<V extends string | number = number> extends Valu
1860
1860
  name?: string;
1861
1861
  motionValue?: MotionValue<V>;
1862
1862
  from?: V;
1863
+ isGenerator?: boolean;
1863
1864
  }
1864
1865
  interface AnimationScope<T = any> {
1865
1866
  readonly current: T;
@@ -4913,6 +4914,7 @@ declare abstract class BaseAnimation<T extends string | number, Resolved> implem
4913
4914
  protected _resolved: Resolved & {
4914
4915
  keyframes: ResolvedKeyframes<T>;
4915
4916
  };
4917
+ protected hasAttemptedResolve: boolean;
4916
4918
  protected resolver: KeyframeResolver<T>;
4917
4919
  constructor({ autoplay, delay, type, repeat, repeatDelay, repeatType, ...options }: ValueAnimationOptions<T>);
4918
4920
  protected abstract initPlayback(keyframes: ResolvedKeyframes<T>, finalKeyframe?: T): Resolved | false;
@@ -815,8 +815,9 @@
815
815
  */
816
816
  const xTranslate = delta.x.translate / treeScale.x;
817
817
  const yTranslate = delta.y.translate / treeScale.y;
818
- if (xTranslate || yTranslate) {
819
- transform = `translate3d(${xTranslate}px, ${yTranslate}px, 0) `;
818
+ const zTranslate = (latestTransform === null || latestTransform === void 0 ? void 0 : latestTransform.z) || 0;
819
+ if (xTranslate || yTranslate || zTranslate) {
820
+ transform = `translate3d(${xTranslate}px, ${yTranslate}px, ${zTranslate}px) `;
820
821
  }
821
822
  /**
822
823
  * Apply scale correction for the tree transform.
@@ -1008,7 +1009,7 @@
1008
1009
  * This will be replaced by the build step with the latest version number.
1009
1010
  * When MotionValues are provided to motion components, warn if versions are mixed.
1010
1011
  */
1011
- this.version = "11.0.21";
1012
+ this.version = "11.0.22";
1012
1013
  /**
1013
1014
  * Tracks whether this value can output a velocity. Currently this is only true
1014
1015
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -2254,6 +2255,7 @@
2254
2255
  constructor({ autoplay = true, delay = 0, type = "keyframes", repeat = 0, repeatDelay = 0, repeatType = "loop", ...options }) {
2255
2256
  // Track whether the animation has been stopped. Stopped animations won't restart.
2256
2257
  this.isStopped = false;
2258
+ this.hasAttemptedResolve = false;
2257
2259
  this.options = {
2258
2260
  autoplay,
2259
2261
  delay,
@@ -2271,8 +2273,9 @@
2271
2273
  * This is a deoptimisation, but at its worst still batches read/writes.
2272
2274
  */
2273
2275
  get resolved() {
2274
- if (!this._resolved)
2276
+ if (!this._resolved && !this.hasAttemptedResolve) {
2275
2277
  flushKeyframeResolvers();
2278
+ }
2276
2279
  return this._resolved;
2277
2280
  }
2278
2281
  /**
@@ -2281,12 +2284,13 @@
2281
2284
  * Otherwise, it will call initPlayback on the implementing class.
2282
2285
  */
2283
2286
  onKeyframesResolved(keyframes, finalKeyframe) {
2284
- const { name, type, velocity, delay, onComplete, onUpdate } = this.options;
2287
+ this.hasAttemptedResolve = true;
2288
+ const { name, type, velocity, delay, onComplete, onUpdate, isGenerator, } = this.options;
2285
2289
  /**
2286
2290
  * If we can't animate this value with the resolved keyframes
2287
2291
  * then we should complete it immediately.
2288
2292
  */
2289
- if (!canAnimate(keyframes, name, type, velocity)) {
2293
+ if (!isGenerator && !canAnimate(keyframes, name, type, velocity)) {
2290
2294
  // Finish immediately
2291
2295
  if (instantAnimationState.current || !delay) {
2292
2296
  onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(getFinalKeyframe(keyframes, this.options, finalKeyframe));
@@ -3503,6 +3507,7 @@
3503
3507
  keyframes,
3504
3508
  repeat: 0,
3505
3509
  delay: 0,
3510
+ isGenerator: true,
3506
3511
  });
3507
3512
  let state = { done: false, value: keyframes[0] };
3508
3513
  const pregeneratedKeyframes = [];
@@ -3547,6 +3552,12 @@
3547
3552
  const { onComplete, onUpdate, motionValue, ...options } = this.options;
3548
3553
  const pregeneratedAnimation = pregenerateKeyframes(keyframes, options);
3549
3554
  keyframes = pregeneratedAnimation.keyframes;
3555
+ // If this is a very short animation, ensure we have
3556
+ // at least two keyframes to animate between as older browsers
3557
+ // can't animate between a single keyframe.
3558
+ if (keyframes.length === 1) {
3559
+ keyframes[1] = keyframes[0];
3560
+ }
3550
3561
  duration = pregeneratedAnimation.duration;
3551
3562
  times = pregeneratedAnimation.times;
3552
3563
  ease = pregeneratedAnimation.ease;
@@ -3695,6 +3706,7 @@
3695
3706
  type,
3696
3707
  ease,
3697
3708
  times,
3709
+ isGenerator: true,
3698
3710
  });
3699
3711
  const sampleTime = secondsToMilliseconds(this.time);
3700
3712
  motionValue.setWithVelocity(sampleAnimation.sample(sampleTime - sampleDelta).value, sampleAnimation.sample(sampleTime).value, sampleDelta);
@@ -3955,7 +3967,7 @@
3955
3967
  * and warn against mismatches.
3956
3968
  */
3957
3969
  {
3958
- warnOnce(nextValue.version === "11.0.21", `Attempting to mix Framer Motion versions ${nextValue.version} with 11.0.21 may not work as expected.`);
3970
+ warnOnce(nextValue.version === "11.0.22", `Attempting to mix Framer Motion versions ${nextValue.version} with 11.0.22 may not work as expected.`);
3959
3971
  }
3960
3972
  }
3961
3973
  else if (isMotionValue(prevValue)) {
@@ -5887,7 +5899,8 @@
5887
5899
  * skipping the nested loop and new object creation is 50% faster.
5888
5900
  */
5889
5901
  const { latestValues } = visualElement;
5890
- if (latestValues.rotate ||
5902
+ if (latestValues.z ||
5903
+ latestValues.rotate ||
5891
5904
  latestValues.rotateX ||
5892
5905
  latestValues.rotateY ||
5893
5906
  latestValues.rotateZ ||
@@ -5899,6 +5912,9 @@
5899
5912
  if (!hasDistortingTransform)
5900
5913
  return;
5901
5914
  const resetValues = {};
5915
+ if (latestValues.z) {
5916
+ resetDistortingTransform("z", visualElement, resetValues, this.animationValues);
5917
+ }
5902
5918
  // Check the skew and rotate value of all axes and reset to 0
5903
5919
  for (let i = 0; i < transformAxes.length; i++) {
5904
5920
  resetDistortingTransform(`rotate${transformAxes[i]}`, visualElement, resetValues, this.animationValues);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "framer-motion",
3
- "version": "11.0.21",
3
+ "version": "11.0.23",
4
4
  "description": "A simple and powerful JavaScript animation library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.mjs",
@@ -87,7 +87,7 @@
87
87
  "bundlesize": [
88
88
  {
89
89
  "path": "./dist/size-rollup-motion.js",
90
- "maxSize": "32.4 kB"
90
+ "maxSize": "32.5 kB"
91
91
  },
92
92
  {
93
93
  "path": "./dist/size-rollup-m.js",
@@ -95,11 +95,11 @@
95
95
  },
96
96
  {
97
97
  "path": "./dist/size-rollup-dom-animation.js",
98
- "maxSize": "16.25kB"
98
+ "maxSize": "16.3kB"
99
99
  },
100
100
  {
101
101
  "path": "./dist/size-rollup-dom-max.js",
102
- "maxSize": "27.8 kB"
102
+ "maxSize": "27.85 kB"
103
103
  },
104
104
  {
105
105
  "path": "./dist/size-rollup-animate.js",
@@ -115,8 +115,8 @@
115
115
  },
116
116
  {
117
117
  "path": "./dist/size-webpack-dom-max.js",
118
- "maxSize": "33.3 kB"
118
+ "maxSize": "33.4 kB"
119
119
  }
120
120
  ],
121
- "gitHead": "92addac7b04e903027e34578a28cc348a78f9bea"
121
+ "gitHead": "ddf2362973c18ffdca717441dfbef077fd2f098f"
122
122
  }