framer-motion 12.10.2 → 12.10.4

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.
@@ -2059,10 +2059,12 @@
2059
2059
  * This method is bound to the instance to fix a pattern where
2060
2060
  * animation.stop is returned as a reference from a useEffect.
2061
2061
  */
2062
- this.stop = () => {
2063
- const { motionValue } = this.options;
2064
- if (motionValue && motionValue.updatedAt !== time.now()) {
2065
- this.tick(time.now());
2062
+ this.stop = (sync = true) => {
2063
+ if (sync) {
2064
+ const { motionValue } = this.options;
2065
+ if (motionValue && motionValue.updatedAt !== time.now()) {
2066
+ this.tick(time.now());
2067
+ }
2066
2068
  }
2067
2069
  this.isStopped = true;
2068
2070
  if (this.state === "idle")
@@ -5290,7 +5292,9 @@
5290
5292
  return;
5291
5293
  }
5292
5294
  }
5293
- return new AsyncMotionValueAnimation(options);
5295
+ return valueTransition.isSync
5296
+ ? new JSAnimation(options)
5297
+ : new AsyncMotionValueAnimation(options);
5294
5298
  };
5295
5299
 
5296
5300
  function animateSingleValue(value, keyframes, options) {
@@ -6928,10 +6932,8 @@
6928
6932
  }
6929
6933
  startAnimation(options) {
6930
6934
  this.notifyListeners("animationStart");
6931
- this.currentAnimation && this.currentAnimation.stop();
6932
- if (this.resumingFrom && this.resumingFrom.currentAnimation) {
6933
- this.resumingFrom.currentAnimation.stop();
6934
- }
6935
+ this.currentAnimation?.stop(false);
6936
+ this.resumingFrom?.currentAnimation?.stop(false);
6935
6937
  if (this.pendingAnimation) {
6936
6938
  cancelFrame(this.pendingAnimation);
6937
6939
  this.pendingAnimation = undefined;
@@ -6944,8 +6946,10 @@
6944
6946
  this.pendingAnimation = frame.update(() => {
6945
6947
  globalProjectionState.hasAnimatedSinceResize = true;
6946
6948
  activeAnimations.layout++;
6947
- this.currentAnimation = animateSingleValue(0, animationTarget, {
6949
+ this.motionValue || (this.motionValue = motionValue(0));
6950
+ this.currentAnimation = animateSingleValue(this.motionValue, [0, 1000], {
6948
6951
  ...options,
6952
+ isSync: true,
6949
6953
  onUpdate: (latest) => {
6950
6954
  this.mixTargetDelta(latest);
6951
6955
  options.onUpdate && options.onUpdate(latest);
@@ -6981,7 +6985,7 @@
6981
6985
  finishAnimation() {
6982
6986
  if (this.currentAnimation) {
6983
6987
  this.mixTargetDelta && this.mixTargetDelta(animationTarget);
6984
- this.currentAnimation.stop();
6988
+ this.currentAnimation.stop(false);
6985
6989
  }
6986
6990
  this.completeAnimation();
6987
6991
  }
@@ -7246,7 +7250,7 @@
7246
7250
  }
7247
7251
  // Only run on root
7248
7252
  resetTree() {
7249
- this.root.nodes.forEach((node) => node.currentAnimation?.stop());
7253
+ this.root.nodes.forEach((node) => node.currentAnimation?.stop(false));
7250
7254
  this.root.nodes.forEach(clearMeasurements);
7251
7255
  this.root.sharedNodes.clear();
7252
7256
  }