framer-motion 11.3.25-alpha.9 → 11.3.26

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.
@@ -96,6 +96,7 @@ const stepsOrder = [
96
96
  "render", // Write
97
97
  "postRender", // Compute
98
98
  ];
99
+ const maxElapsed$1 = 40;
99
100
  function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
100
101
  let runNextFrame = false;
101
102
  let useDefaultElapsed = true;
@@ -115,7 +116,7 @@ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
115
116
  runNextFrame = false;
116
117
  state.delta = useDefaultElapsed
117
118
  ? 1000 / 60
118
- : Math.max(timestamp - state.timestamp, 1);
119
+ : Math.max(Math.min(timestamp - state.timestamp, maxElapsed$1), 1);
119
120
  state.timestamp = timestamp;
120
121
  state.isProcessing = true;
121
122
  // Unrolled render loop for better per-frame performance
@@ -278,7 +279,7 @@ class MotionValue {
278
279
  * This will be replaced by the build step with the latest version number.
279
280
  * When MotionValues are provided to motion components, warn if versions are mixed.
280
281
  */
281
- this.version = "11.3.25-alpha.9";
282
+ this.version = "11.3.26";
282
283
  /**
283
284
  * Tracks whether this value can output a velocity. Currently this is only true
284
285
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -677,9 +678,6 @@ class GroupPlaybackControls {
677
678
  set speed(speed) {
678
679
  this.setAll("speed", speed);
679
680
  }
680
- get startTime() {
681
- return this.getAll("startTime");
682
- }
683
681
  get duration() {
684
682
  let max = 0;
685
683
  for (let i = 0; i < this.animations.length; i++) {
@@ -2645,6 +2643,10 @@ class MainThreadAnimation extends BaseAnimation {
2645
2643
  * The time at which the animation was paused.
2646
2644
  */
2647
2645
  this.holdTime = null;
2646
+ /**
2647
+ * The time at which the animation was started.
2648
+ */
2649
+ this.startTime = null;
2648
2650
  /**
2649
2651
  * The time at which the animation was cancelled.
2650
2652
  */
@@ -2663,11 +2665,6 @@ class MainThreadAnimation extends BaseAnimation {
2663
2665
  * without us having to resolve it first.
2664
2666
  */
2665
2667
  this.pendingPlayState = "running";
2666
- /**
2667
- * The time at which the animation was started.
2668
- */
2669
- this.startTime = null;
2670
- this.log = false;
2671
2668
  this.state = "idle";
2672
2669
  /**
2673
2670
  * This method is bound to the instance to fix a pattern where
@@ -2682,17 +2679,10 @@ class MainThreadAnimation extends BaseAnimation {
2682
2679
  const { onStop } = this.options;
2683
2680
  onStop && onStop();
2684
2681
  };
2685
- const { name, motionValue, element, keyframes, isGenerator } = this.options;
2682
+ const { name, motionValue, element, keyframes } = this.options;
2686
2683
  const KeyframeResolver$1 = (element === null || element === void 0 ? void 0 : element.KeyframeResolver) || KeyframeResolver;
2687
2684
  const onResolved = (resolvedKeyframes, finalKeyframe) => this.onKeyframesResolved(resolvedKeyframes, finalKeyframe);
2688
- const urlParams = new URLSearchParams(window.location.search);
2689
- const logId = urlParams.get("log-id");
2690
- if (element &&
2691
- logId &&
2692
- element.getProps()["data-framer-appear-id"] === logId) {
2693
- this.log = true;
2694
- }
2695
- this.resolver = new KeyframeResolver$1(keyframes, onResolved, name, motionValue, element, !isGenerator);
2685
+ this.resolver = new KeyframeResolver$1(keyframes, onResolved, name, motionValue, element);
2696
2686
  this.resolver.scheduleResolve();
2697
2687
  }
2698
2688
  initPlayback(keyframes$1) {
@@ -2874,9 +2864,6 @@ class MainThreadAnimation extends BaseAnimation {
2874
2864
  if (isAnimationFinished && finalKeyframe !== undefined) {
2875
2865
  state.value = getFinalKeyframe(keyframes, this.options, finalKeyframe);
2876
2866
  }
2877
- if (this.log) {
2878
- console.log("startTime", this.startTime, "elapsed", elapsed, "value", state.value);
2879
- }
2880
2867
  if (onUpdate) {
2881
2868
  onUpdate(state.value);
2882
2869
  }
@@ -2922,20 +2909,16 @@ class MainThreadAnimation extends BaseAnimation {
2922
2909
  }
2923
2910
  if (this.isStopped)
2924
2911
  return;
2925
- const { driver = frameloopDriver, onPlay, startTime } = this.options;
2912
+ const { driver = frameloopDriver, onPlay } = this.options;
2926
2913
  if (!this.driver) {
2927
2914
  this.driver = driver((timestamp) => this.tick(timestamp));
2928
2915
  }
2929
2916
  onPlay && onPlay();
2930
- const now = this.driver.now();
2931
2917
  if (this.holdTime !== null) {
2932
- this.startTime = now - this.holdTime;
2933
- }
2934
- else if (!this.startTime) {
2935
- this.startTime = startTime !== null && startTime !== void 0 ? startTime : this.calcStartTime();
2918
+ this.startTime = this.driver.now() - this.holdTime;
2936
2919
  }
2937
- else if (this.state === "finished") {
2938
- this.startTime = now;
2920
+ else if (!this.startTime || this.state === "finished") {
2921
+ this.startTime = this.calcStartTime();
2939
2922
  }
2940
2923
  if (this.state === "finished") {
2941
2924
  this.updateFinishedPromise();
@@ -3131,7 +3114,7 @@ class AcceleratedAnimation extends BaseAnimation {
3131
3114
  }
3132
3115
  initPlayback(keyframes, finalKeyframe) {
3133
3116
  var _a;
3134
- let { duration = 300, times, ease, type, motionValue, name, startTime, } = this.options;
3117
+ let { duration = 300, times, ease, type, motionValue, name, } = this.options;
3135
3118
  /**
3136
3119
  * If element has since been unmounted, return false to indicate
3137
3120
  * the animation failed to initialised.
@@ -3160,7 +3143,7 @@ class AcceleratedAnimation extends BaseAnimation {
3160
3143
  const animation = animateStyle(motionValue.owner.current, name, keyframes, { ...this.options, duration, times, ease });
3161
3144
  // Override the browser calculated startTime with one synchronised to other JS
3162
3145
  // and WAAPI animations starting this event loop.
3163
- animation.startTime = startTime !== null && startTime !== void 0 ? startTime : this.calcStartTime();
3146
+ animation.startTime = this.calcStartTime();
3164
3147
  if (this.pendingTimeline) {
3165
3148
  animation.timeline = this.pendingTimeline;
3166
3149
  this.pendingTimeline = undefined;
@@ -3233,15 +3216,6 @@ class AcceleratedAnimation extends BaseAnimation {
3233
3216
  const { animation } = resolved;
3234
3217
  return animation.playState;
3235
3218
  }
3236
- get startTime() {
3237
- const { resolved } = this;
3238
- if (!resolved)
3239
- return null;
3240
- const { animation } = resolved;
3241
- // Coerce to number as TypeScript incorrectly types this
3242
- // as CSSNumberish
3243
- return animation.startTime;
3244
- }
3245
3219
  /**
3246
3220
  * Replace the default DocumentTimeline with another AnimationTimeline.
3247
3221
  * Currently used for scroll animations.
@@ -3352,7 +3326,7 @@ class AcceleratedAnimation extends BaseAnimation {
3352
3326
  }
3353
3327
  }
3354
3328
 
3355
- const animateMotionValue = (name, value, target, transition = {}, element,
3329
+ const animateMotionValue = (name, value, target, transition = {}, element, isHandoff,
3356
3330
  /**
3357
3331
  * Currently used to remove values from will-change when an animation ends.
3358
3332
  * Preferably this would be handled by event listeners on the MotionValue
@@ -3371,7 +3345,7 @@ onEnd) => (onComplete) => {
3371
3345
  * Elapsed isn't a public transition option but can be passed through from
3372
3346
  * optimized appear effects in milliseconds.
3373
3347
  */
3374
- let { elapsed = 0, isHandoff } = transition;
3348
+ let { elapsed = 0 } = transition;
3375
3349
  elapsed = elapsed - secondsToMilliseconds(delay);
3376
3350
  let options = {
3377
3351
  keyframes: Array.isArray(target) ? target : [null, target],
@@ -3645,7 +3619,7 @@ function animateTarget(visualElement, targetAndTransition, { delay = 0, transiti
3645
3619
  shouldBlockAnimation(animationTypeState, key))) {
3646
3620
  continue;
3647
3621
  }
3648
- let valueTransition = {
3622
+ const valueTransition = {
3649
3623
  delay,
3650
3624
  elapsed: 0,
3651
3625
  ...getValueTransition$1(transition || {}, key),
@@ -3654,22 +3628,20 @@ function animateTarget(visualElement, targetAndTransition, { delay = 0, transiti
3654
3628
  * If this is the first time a value is being animated, check
3655
3629
  * to see if we're handling off from an existing animation.
3656
3630
  */
3631
+ let isHandoff = false;
3657
3632
  if (window.MotionHandoffAnimation) {
3658
3633
  const appearId = getOptimisedAppearId(visualElement);
3659
3634
  if (appearId) {
3660
- const info = window.MotionHandoffAnimation(appearId, key, frame);
3661
- if (info !== null) {
3662
- valueTransition = {
3663
- ...valueTransition,
3664
- ...info,
3665
- isHandoff: true,
3666
- };
3635
+ const elapsed = window.MotionHandoffAnimation(appearId, key, frame);
3636
+ if (elapsed !== null) {
3637
+ valueTransition.elapsed = elapsed;
3638
+ isHandoff = true;
3667
3639
  }
3668
3640
  }
3669
3641
  }
3670
3642
  value.start(animateMotionValue(key, value, valueTarget, visualElement.shouldReduceMotion && transformProps.has(key)
3671
3643
  ? { type: false }
3672
- : valueTransition, visualElement, addValueToWillChange(visualElement, key)));
3644
+ : valueTransition, visualElement, isHandoff, addValueToWillChange(visualElement, key)));
3673
3645
  const animation = value.animation;
3674
3646
  if (animation) {
3675
3647
  animations.push(animation);
@@ -3803,7 +3775,7 @@ function updateMotionValuesFromProps(element, next, prev) {
3803
3775
  * and warn against mismatches.
3804
3776
  */
3805
3777
  if (process.env.NODE_ENV === "development") {
3806
- warnOnce(nextValue.version === "11.3.25-alpha.9", `Attempting to mix Framer Motion versions ${nextValue.version} with 11.3.25-alpha.9 may not work as expected.`);
3778
+ warnOnce(nextValue.version === "11.3.26", `Attempting to mix Framer Motion versions ${nextValue.version} with 11.3.26 may not work as expected.`);
3807
3779
  }
3808
3780
  }
3809
3781
  else if (isMotionValue(prevValue)) {
package/dist/cjs/index.js CHANGED
@@ -146,6 +146,7 @@ const stepsOrder = [
146
146
  "render", // Write
147
147
  "postRender", // Compute
148
148
  ];
149
+ const maxElapsed$1 = 40;
149
150
  function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
150
151
  let runNextFrame = false;
151
152
  let useDefaultElapsed = true;
@@ -167,7 +168,7 @@ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
167
168
  runNextFrame = false;
168
169
  state.delta = useDefaultElapsed
169
170
  ? 1000 / 60
170
- : Math.max(timestamp - state.timestamp, 1);
171
+ : Math.max(Math.min(timestamp - state.timestamp, maxElapsed$1), 1);
171
172
  state.timestamp = timestamp;
172
173
  state.isProcessing = true;
173
174
  // Unrolled render loop for better per-frame performance
@@ -3892,6 +3893,10 @@ class MainThreadAnimation extends BaseAnimation {
3892
3893
  * The time at which the animation was paused.
3893
3894
  */
3894
3895
  this.holdTime = null;
3896
+ /**
3897
+ * The time at which the animation was started.
3898
+ */
3899
+ this.startTime = null;
3895
3900
  /**
3896
3901
  * The time at which the animation was cancelled.
3897
3902
  */
@@ -3910,11 +3915,6 @@ class MainThreadAnimation extends BaseAnimation {
3910
3915
  * without us having to resolve it first.
3911
3916
  */
3912
3917
  this.pendingPlayState = "running";
3913
- /**
3914
- * The time at which the animation was started.
3915
- */
3916
- this.startTime = null;
3917
- this.log = false;
3918
3918
  this.state = "idle";
3919
3919
  /**
3920
3920
  * This method is bound to the instance to fix a pattern where
@@ -3929,17 +3929,10 @@ class MainThreadAnimation extends BaseAnimation {
3929
3929
  const { onStop } = this.options;
3930
3930
  onStop && onStop();
3931
3931
  };
3932
- const { name, motionValue, element, keyframes, isGenerator } = this.options;
3932
+ const { name, motionValue, element, keyframes } = this.options;
3933
3933
  const KeyframeResolver$1 = (element === null || element === void 0 ? void 0 : element.KeyframeResolver) || KeyframeResolver;
3934
3934
  const onResolved = (resolvedKeyframes, finalKeyframe) => this.onKeyframesResolved(resolvedKeyframes, finalKeyframe);
3935
- const urlParams = new URLSearchParams(window.location.search);
3936
- const logId = urlParams.get("log-id");
3937
- if (element &&
3938
- logId &&
3939
- element.getProps()["data-framer-appear-id"] === logId) {
3940
- this.log = true;
3941
- }
3942
- this.resolver = new KeyframeResolver$1(keyframes, onResolved, name, motionValue, element, !isGenerator);
3935
+ this.resolver = new KeyframeResolver$1(keyframes, onResolved, name, motionValue, element);
3943
3936
  this.resolver.scheduleResolve();
3944
3937
  }
3945
3938
  initPlayback(keyframes$1) {
@@ -4121,9 +4114,6 @@ class MainThreadAnimation extends BaseAnimation {
4121
4114
  if (isAnimationFinished && finalKeyframe !== undefined) {
4122
4115
  state.value = getFinalKeyframe(keyframes, this.options, finalKeyframe);
4123
4116
  }
4124
- if (this.log) {
4125
- console.log("startTime", this.startTime, "elapsed", elapsed, "value", state.value);
4126
- }
4127
4117
  if (onUpdate) {
4128
4118
  onUpdate(state.value);
4129
4119
  }
@@ -4169,20 +4159,16 @@ class MainThreadAnimation extends BaseAnimation {
4169
4159
  }
4170
4160
  if (this.isStopped)
4171
4161
  return;
4172
- const { driver = frameloopDriver, onPlay, startTime } = this.options;
4162
+ const { driver = frameloopDriver, onPlay } = this.options;
4173
4163
  if (!this.driver) {
4174
4164
  this.driver = driver((timestamp) => this.tick(timestamp));
4175
4165
  }
4176
4166
  onPlay && onPlay();
4177
- const now = this.driver.now();
4178
4167
  if (this.holdTime !== null) {
4179
- this.startTime = now - this.holdTime;
4180
- }
4181
- else if (!this.startTime) {
4182
- this.startTime = startTime !== null && startTime !== void 0 ? startTime : this.calcStartTime();
4168
+ this.startTime = this.driver.now() - this.holdTime;
4183
4169
  }
4184
- else if (this.state === "finished") {
4185
- this.startTime = now;
4170
+ else if (!this.startTime || this.state === "finished") {
4171
+ this.startTime = this.calcStartTime();
4186
4172
  }
4187
4173
  if (this.state === "finished") {
4188
4174
  this.updateFinishedPromise();
@@ -4369,7 +4355,7 @@ class AcceleratedAnimation extends BaseAnimation {
4369
4355
  }
4370
4356
  initPlayback(keyframes, finalKeyframe) {
4371
4357
  var _a;
4372
- let { duration = 300, times, ease, type, motionValue, name, startTime, } = this.options;
4358
+ let { duration = 300, times, ease, type, motionValue, name, } = this.options;
4373
4359
  /**
4374
4360
  * If element has since been unmounted, return false to indicate
4375
4361
  * the animation failed to initialised.
@@ -4398,7 +4384,7 @@ class AcceleratedAnimation extends BaseAnimation {
4398
4384
  const animation = animateStyle(motionValue.owner.current, name, keyframes, { ...this.options, duration, times, ease });
4399
4385
  // Override the browser calculated startTime with one synchronised to other JS
4400
4386
  // and WAAPI animations starting this event loop.
4401
- animation.startTime = startTime !== null && startTime !== void 0 ? startTime : this.calcStartTime();
4387
+ animation.startTime = this.calcStartTime();
4402
4388
  if (this.pendingTimeline) {
4403
4389
  animation.timeline = this.pendingTimeline;
4404
4390
  this.pendingTimeline = undefined;
@@ -4471,15 +4457,6 @@ class AcceleratedAnimation extends BaseAnimation {
4471
4457
  const { animation } = resolved;
4472
4458
  return animation.playState;
4473
4459
  }
4474
- get startTime() {
4475
- const { resolved } = this;
4476
- if (!resolved)
4477
- return null;
4478
- const { animation } = resolved;
4479
- // Coerce to number as TypeScript incorrectly types this
4480
- // as CSSNumberish
4481
- return animation.startTime;
4482
- }
4483
4460
  /**
4484
4461
  * Replace the default DocumentTimeline with another AnimationTimeline.
4485
4462
  * Currently used for scroll animations.
@@ -4659,9 +4636,6 @@ class GroupPlaybackControls {
4659
4636
  set speed(speed) {
4660
4637
  this.setAll("speed", speed);
4661
4638
  }
4662
- get startTime() {
4663
- return this.getAll("startTime");
4664
- }
4665
4639
  get duration() {
4666
4640
  let max = 0;
4667
4641
  for (let i = 0; i < this.animations.length; i++) {
@@ -4686,7 +4660,7 @@ class GroupPlaybackControls {
4686
4660
  }
4687
4661
  }
4688
4662
 
4689
- const animateMotionValue = (name, value, target, transition = {}, element,
4663
+ const animateMotionValue = (name, value, target, transition = {}, element, isHandoff,
4690
4664
  /**
4691
4665
  * Currently used to remove values from will-change when an animation ends.
4692
4666
  * Preferably this would be handled by event listeners on the MotionValue
@@ -4705,7 +4679,7 @@ onEnd) => (onComplete) => {
4705
4679
  * Elapsed isn't a public transition option but can be passed through from
4706
4680
  * optimized appear effects in milliseconds.
4707
4681
  */
4708
- let { elapsed = 0, isHandoff } = transition;
4682
+ let { elapsed = 0 } = transition;
4709
4683
  elapsed = elapsed - secondsToMilliseconds(delay);
4710
4684
  let options = {
4711
4685
  keyframes: Array.isArray(target) ? target : [null, target],
@@ -4872,7 +4846,7 @@ class MotionValue {
4872
4846
  * This will be replaced by the build step with the latest version number.
4873
4847
  * When MotionValues are provided to motion components, warn if versions are mixed.
4874
4848
  */
4875
- this.version = "11.3.25-alpha.9";
4849
+ this.version = "11.3.26";
4876
4850
  /**
4877
4851
  * Tracks whether this value can output a velocity. Currently this is only true
4878
4852
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -5276,7 +5250,7 @@ function animateTarget(visualElement, targetAndTransition, { delay = 0, transiti
5276
5250
  shouldBlockAnimation(animationTypeState, key))) {
5277
5251
  continue;
5278
5252
  }
5279
- let valueTransition = {
5253
+ const valueTransition = {
5280
5254
  delay,
5281
5255
  elapsed: 0,
5282
5256
  ...getValueTransition$1(transition || {}, key),
@@ -5285,22 +5259,20 @@ function animateTarget(visualElement, targetAndTransition, { delay = 0, transiti
5285
5259
  * If this is the first time a value is being animated, check
5286
5260
  * to see if we're handling off from an existing animation.
5287
5261
  */
5262
+ let isHandoff = false;
5288
5263
  if (window.MotionHandoffAnimation) {
5289
5264
  const appearId = getOptimisedAppearId(visualElement);
5290
5265
  if (appearId) {
5291
- const info = window.MotionHandoffAnimation(appearId, key, frame);
5292
- if (info !== null) {
5293
- valueTransition = {
5294
- ...valueTransition,
5295
- ...info,
5296
- isHandoff: true,
5297
- };
5266
+ const elapsed = window.MotionHandoffAnimation(appearId, key, frame);
5267
+ if (elapsed !== null) {
5268
+ valueTransition.elapsed = elapsed;
5269
+ isHandoff = true;
5298
5270
  }
5299
5271
  }
5300
5272
  }
5301
5273
  value.start(animateMotionValue(key, value, valueTarget, visualElement.shouldReduceMotion && transformProps.has(key)
5302
5274
  ? { type: false }
5303
- : valueTransition, visualElement, addValueToWillChange(visualElement, key)));
5275
+ : valueTransition, visualElement, isHandoff, addValueToWillChange(visualElement, key)));
5304
5276
  const animation = value.animation;
5305
5277
  if (animation) {
5306
5278
  animations.push(animation);
@@ -6612,7 +6584,7 @@ class VisualElementDragControls {
6612
6584
  }
6613
6585
  startAxisValueAnimation(axis, transition) {
6614
6586
  const axisValue = this.getAxisMotionValue(axis);
6615
- return axisValue.start(animateMotionValue(axis, axisValue, 0, transition, this.visualElement, addValueToWillChange(this.visualElement, axis)));
6587
+ return axisValue.start(animateMotionValue(axis, axisValue, 0, transition, this.visualElement, false, addValueToWillChange(this.visualElement, axis)));
6616
6588
  }
6617
6589
  stopAnimation() {
6618
6590
  eachAxis((axis) => this.getAxisMotionValue(axis).stop());
@@ -7336,7 +7308,7 @@ function updateMotionValuesFromProps(element, next, prev) {
7336
7308
  * and warn against mismatches.
7337
7309
  */
7338
7310
  if (process.env.NODE_ENV === "development") {
7339
- warnOnce(nextValue.version === "11.3.25-alpha.9", `Attempting to mix Framer Motion versions ${nextValue.version} with 11.3.25-alpha.9 may not work as expected.`);
7311
+ warnOnce(nextValue.version === "11.3.26", `Attempting to mix Framer Motion versions ${nextValue.version} with 11.3.26 may not work as expected.`);
7340
7312
  }
7341
7313
  }
7342
7314
  else if (isMotionValue(prevValue)) {
@@ -8971,30 +8943,23 @@ function resetDistortingTransform(key, visualElement, values, sharedAnimationVal
8971
8943
  }
8972
8944
  }
8973
8945
  }
8974
- function cancelTreeOptimisedTransformAnimations(projectionNode) {
8946
+ function isOptimisedTransformAnimationInTree(projectionNode) {
8975
8947
  projectionNode.hasCheckedOptimisedAppear = true;
8976
8948
  if (projectionNode.root === projectionNode)
8977
- return;
8949
+ return false;
8978
8950
  const { visualElement } = projectionNode.options;
8979
- if (!visualElement)
8980
- return;
8981
- const appearId = getOptimisedAppearId(visualElement);
8982
- if (window.MotionHasOptimisedTransformAnimation(appearId)) {
8983
- const now = performance.now();
8984
- console.log(now, time.now());
8985
- frameData.delta = 8;
8986
- frameData.timestamp = now;
8987
- frameData.isProcessing = true;
8988
- flushKeyframeResolvers();
8989
- steps.update.process(frameData);
8990
- steps.preRender.process(frameData);
8991
- steps.render.process(frameData);
8992
- frameData.isProcessing = false;
8993
- window.MotionCancelOptimisedTransform(appearId);
8994
- }
8995
- const { parent } = projectionNode;
8996
- if (parent && !parent.hasCheckedOptimisedAppear) {
8997
- cancelTreeOptimisedTransformAnimations(parent);
8951
+ if (!visualElement) {
8952
+ return false;
8953
+ }
8954
+ else if (window.MotionHasOptimisedTransformAnimation(getOptimisedAppearId(visualElement))) {
8955
+ return true;
8956
+ }
8957
+ else if (projectionNode.parent &&
8958
+ !projectionNode.parent.hasCheckedOptimisedAppear) {
8959
+ return isOptimisedTransformAnimationInTree(projectionNode.parent);
8960
+ }
8961
+ else {
8962
+ return false;
8998
8963
  }
8999
8964
  }
9000
8965
  function createProjectionNode({ attachResizeListener, defaultParent, measureScroll, checkIsScrollRoot, resetTransform, }) {
@@ -9318,9 +9283,9 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
9318
9283
  * snapshots in startUpdate(), but we only want to cancel optimised animations
9319
9284
  * if a layout animation measurement is actually going to be affected by them.
9320
9285
  */
9321
- if (window.MotionCancelOptimisedTransform &&
9322
- !this.hasCheckedOptimisedAppear) {
9323
- cancelTreeOptimisedTransformAnimations(this);
9286
+ if (window.MotionHandoffCancelAll &&
9287
+ isOptimisedTransformAnimationInTree(this)) {
9288
+ window.MotionHandoffCancelAll();
9324
9289
  }
9325
9290
  !this.root.isUpdating && this.root.startUpdate();
9326
9291
  if (this.isLayoutDirty)
@@ -12251,10 +12216,7 @@ function handoffOptimizedAppearAnimation(elementId, valueName, frame) {
12251
12216
  * an updated value for several frames, even as the animation plays smoothly via
12252
12217
  * the GPU.
12253
12218
  */
12254
- return {
12255
- elapsed: handoffFrameTime - startTime || 0,
12256
- startTime: handoffFrameTime,
12257
- };
12219
+ return handoffFrameTime - startTime || 0;
12258
12220
  }
12259
12221
  }
12260
12222
 
@@ -12298,24 +12260,19 @@ function startOptimizedAppearAnimation(element, name, keyframes, options, onRead
12298
12260
  * of handoff animations.
12299
12261
  */
12300
12262
  window.MotionHandoffAnimation = handoffOptimizedAppearAnimation;
12301
- window.MotionHasOptimisedTransformAnimation = (elementId) => {
12302
- if (!elementId)
12303
- return false;
12304
- const animationId = appearStoreId(elementId, "transform");
12305
- return Boolean(appearAnimationStore.get(animationId));
12306
- };
12307
12263
  /**
12308
12264
  * We only need to cancel transform animations as
12309
12265
  * they're the ones that will interfere with the
12310
12266
  * layout animation measurements.
12311
12267
  */
12312
- window.MotionCancelOptimisedTransform = (elementId) => {
12313
- const animationId = appearStoreId(elementId, "transform");
12314
- const data = appearAnimationStore.get(animationId);
12315
- if (data) {
12316
- data.animation.cancel();
12317
- appearAnimationStore.delete(animationId);
12318
- }
12268
+ window.MotionHandoffCancelAll = () => {
12269
+ appearAnimationStore.forEach(({ animation }, animationId) => {
12270
+ if (animationId.endsWith("transform")) {
12271
+ animation.cancel();
12272
+ appearAnimationStore.delete(animationId);
12273
+ }
12274
+ });
12275
+ window.MotionHandoffCancelAll = undefined;
12319
12276
  };
12320
12277
  /**
12321
12278
  * Keep a map of elementIds that have started animating. We check
@@ -12327,6 +12284,8 @@ function startOptimizedAppearAnimation(element, name, keyframes, options, onRead
12327
12284
  * breakpoint.
12328
12285
  */
12329
12286
  window.MotionHasOptimisedAnimation = (elementId) => Boolean(elementId && elementsWithAppearAnimations.has(elementId));
12287
+ window.MotionHasOptimisedTransformAnimation = (elementId) => Boolean(elementId &&
12288
+ appearAnimationStore.has(appearStoreId(elementId, "transform")));
12330
12289
  }
12331
12290
  const startAnimation = () => {
12332
12291
  readyAnimation.cancel();
@@ -310,10 +310,8 @@ interface Transition extends AnimationPlaybackOptions, Omit<SpringOptions, "keyf
310
310
  type?: "decay" | "spring" | "keyframes" | "tween" | "inertia";
311
311
  duration?: number;
312
312
  autoplay?: boolean;
313
- startTime?: number;
314
313
  }
315
314
  interface ValueAnimationTransition<V = any> extends Transition, AnimationPlaybackLifecycles<V> {
316
- isHandoff?: boolean;
317
315
  }
318
316
  interface AnimationScope<T = any> {
319
317
  readonly current: T;
@@ -342,7 +340,6 @@ type ElementOrSelector = Element | Element[] | NodeListOf<Element> | string;
342
340
  interface AnimationPlaybackControls {
343
341
  time: number;
344
342
  speed: number;
345
- startTime: number | null;
346
343
  state?: AnimationPlayState;
347
344
  duration: number;
348
345
  stop: () => void;
@@ -705,7 +702,6 @@ declare class GroupPlaybackControls implements AnimationPlaybackControls {
705
702
  set time(time: number);
706
703
  get speed(): number;
707
704
  set speed(speed: number);
708
- get startTime(): any;
709
705
  get duration(): number;
710
706
  private runAll;
711
707
  play(): void;
@@ -856,11 +852,7 @@ interface FrameData {
856
852
  isProcessing: boolean;
857
853
  }
858
854
 
859
- interface HandoffInfo {
860
- elapsed: number;
861
- startTime: number;
862
- }
863
- type HandoffFunction = (storeId: string, valueName: string, frame: Batcher) => null | HandoffInfo;
855
+ type HandoffFunction = (storeId: string, valueName: string, frame: Batcher) => null | number;
864
856
  /**
865
857
  * The window global object acts as a bridge between our inline script
866
858
  * triggering the optimized appear animations, and Framer Motion.
@@ -869,9 +861,9 @@ declare global {
869
861
  interface Window {
870
862
  MotionHandoffAnimation?: HandoffFunction;
871
863
  MotionHandoffIsComplete?: boolean;
872
- MotionCancelOptimisedTransform?: (id?: string) => void;
873
- MotionHasOptimisedTransformAnimation?: (id?: string) => boolean;
864
+ MotionHandoffCancelAll?: VoidFunction;
874
865
  MotionHasOptimisedAnimation?: (id?: string) => boolean;
866
+ MotionHasOptimisedTransformAnimation?: (id?: string) => boolean;
875
867
  }
876
868
  }
877
869