framer-motion 11.2.7 → 11.2.8

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.
@@ -4434,6 +4434,99 @@
4434
4434
  }
4435
4435
  }
4436
4436
 
4437
+ function observeTimeline(update, timeline) {
4438
+ let prevProgress;
4439
+ const onFrame = () => {
4440
+ const { currentTime } = timeline;
4441
+ const percentage = currentTime === null ? 0 : currentTime.value;
4442
+ const progress = percentage / 100;
4443
+ if (prevProgress !== progress) {
4444
+ update(progress);
4445
+ }
4446
+ prevProgress = progress;
4447
+ };
4448
+ frame.update(onFrame, true);
4449
+ return () => cancelFrame(onFrame);
4450
+ }
4451
+
4452
+ const supportsScrollTimeline = memo(() => window.ScrollTimeline !== undefined);
4453
+
4454
+ class GroupPlaybackControls {
4455
+ constructor(animations) {
4456
+ // Bound to accomodate common `return animation.stop` pattern
4457
+ this.stop = () => this.runAll("stop");
4458
+ this.animations = animations.filter(Boolean);
4459
+ }
4460
+ then(onResolve, onReject) {
4461
+ return Promise.all(this.animations).then(onResolve).catch(onReject);
4462
+ }
4463
+ /**
4464
+ * TODO: Filter out cancelled or stopped animations before returning
4465
+ */
4466
+ getAll(propName) {
4467
+ return this.animations[0][propName];
4468
+ }
4469
+ setAll(propName, newValue) {
4470
+ for (let i = 0; i < this.animations.length; i++) {
4471
+ this.animations[i][propName] = newValue;
4472
+ }
4473
+ }
4474
+ attachTimeline(timeline) {
4475
+ const cancelAll = this.animations.map((animation) => {
4476
+ if (supportsScrollTimeline() && animation.attachTimeline) {
4477
+ animation.attachTimeline(timeline);
4478
+ }
4479
+ else {
4480
+ animation.pause();
4481
+ return observeTimeline((progress) => {
4482
+ animation.time = animation.duration * progress;
4483
+ }, timeline);
4484
+ }
4485
+ });
4486
+ return () => {
4487
+ cancelAll.forEach((cancelTimeline, i) => {
4488
+ if (cancelTimeline)
4489
+ cancelTimeline();
4490
+ this.animations[i].stop();
4491
+ });
4492
+ };
4493
+ }
4494
+ get time() {
4495
+ return this.getAll("time");
4496
+ }
4497
+ set time(time) {
4498
+ this.setAll("time", time);
4499
+ }
4500
+ get speed() {
4501
+ return this.getAll("speed");
4502
+ }
4503
+ set speed(speed) {
4504
+ this.setAll("speed", speed);
4505
+ }
4506
+ get duration() {
4507
+ let max = 0;
4508
+ for (let i = 0; i < this.animations.length; i++) {
4509
+ max = Math.max(max, this.animations[i].duration);
4510
+ }
4511
+ return max;
4512
+ }
4513
+ runAll(methodName) {
4514
+ this.animations.forEach((controls) => controls[methodName]());
4515
+ }
4516
+ play() {
4517
+ this.runAll("play");
4518
+ }
4519
+ pause() {
4520
+ this.runAll("pause");
4521
+ }
4522
+ cancel() {
4523
+ this.runAll("cancel");
4524
+ }
4525
+ complete() {
4526
+ this.runAll("complete");
4527
+ }
4528
+ }
4529
+
4437
4530
  const animateMotionValue = (name, value, target, transition = {}, element, isHandoff) => (onComplete) => {
4438
4531
  const valueTransition = getValueTransition$1(transition, name) || {};
4439
4532
  /**
@@ -4516,7 +4609,9 @@
4516
4609
  options.onUpdate(finalKeyframe);
4517
4610
  options.onComplete();
4518
4611
  });
4519
- return;
4612
+ // We still want to return some animation controls here rather
4613
+ // than returning undefined
4614
+ return new GroupPlaybackControls([]);
4520
4615
  }
4521
4616
  }
4522
4617
  /**
@@ -4633,7 +4728,7 @@
4633
4728
  * This will be replaced by the build step with the latest version number.
4634
4729
  * When MotionValues are provided to motion components, warn if versions are mixed.
4635
4730
  */
4636
- this.version = "11.2.7";
4731
+ this.version = "11.2.8";
4637
4732
  /**
4638
4733
  * Tracks whether this value can output a velocity. Currently this is only true
4639
4734
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -6961,100 +7056,6 @@
6961
7056
 
6962
7057
  const visualElementStore = new WeakMap();
6963
7058
 
6964
- function observeTimeline(update, timeline) {
6965
- let prevProgress;
6966
- const onFrame = () => {
6967
- const { currentTime } = timeline;
6968
- const percentage = currentTime === null ? 0 : currentTime.value;
6969
- const progress = percentage / 100;
6970
- if (prevProgress !== progress) {
6971
- update(progress);
6972
- }
6973
- prevProgress = progress;
6974
- };
6975
- frame.update(onFrame, true);
6976
- return () => cancelFrame(onFrame);
6977
- }
6978
-
6979
- const supportsScrollTimeline = memo(() => window.ScrollTimeline !== undefined);
6980
-
6981
- class GroupPlaybackControls {
6982
- constructor(animations) {
6983
- this.animations = animations.filter(Boolean);
6984
- }
6985
- then(onResolve, onReject) {
6986
- return Promise.all(this.animations).then(onResolve).catch(onReject);
6987
- }
6988
- /**
6989
- * TODO: Filter out cancelled or stopped animations before returning
6990
- */
6991
- getAll(propName) {
6992
- return this.animations[0][propName];
6993
- }
6994
- setAll(propName, newValue) {
6995
- for (let i = 0; i < this.animations.length; i++) {
6996
- this.animations[i][propName] = newValue;
6997
- }
6998
- }
6999
- attachTimeline(timeline) {
7000
- const cancelAll = this.animations.map((animation) => {
7001
- if (supportsScrollTimeline() && animation.attachTimeline) {
7002
- animation.attachTimeline(timeline);
7003
- }
7004
- else {
7005
- animation.pause();
7006
- return observeTimeline((progress) => {
7007
- animation.time = animation.duration * progress;
7008
- }, timeline);
7009
- }
7010
- });
7011
- return () => {
7012
- cancelAll.forEach((cancelTimeline, i) => {
7013
- if (cancelTimeline)
7014
- cancelTimeline();
7015
- this.animations[i].stop();
7016
- });
7017
- };
7018
- }
7019
- get time() {
7020
- return this.getAll("time");
7021
- }
7022
- set time(time) {
7023
- this.setAll("time", time);
7024
- }
7025
- get speed() {
7026
- return this.getAll("speed");
7027
- }
7028
- set speed(speed) {
7029
- this.setAll("speed", speed);
7030
- }
7031
- get duration() {
7032
- let max = 0;
7033
- for (let i = 0; i < this.animations.length; i++) {
7034
- max = Math.max(max, this.animations[i].duration);
7035
- }
7036
- return max;
7037
- }
7038
- runAll(methodName) {
7039
- this.animations.forEach((controls) => controls[methodName]());
7040
- }
7041
- play() {
7042
- this.runAll("play");
7043
- }
7044
- pause() {
7045
- this.runAll("pause");
7046
- }
7047
- stop() {
7048
- this.runAll("stop");
7049
- }
7050
- cancel() {
7051
- this.runAll("cancel");
7052
- }
7053
- complete() {
7054
- this.runAll("complete");
7055
- }
7056
- }
7057
-
7058
7059
  function isDOMKeyframes(keyframes) {
7059
7060
  return typeof keyframes === "object" && !Array.isArray(keyframes);
7060
7061
  }
@@ -7101,7 +7102,7 @@
7101
7102
  * and warn against mismatches.
7102
7103
  */
7103
7104
  {
7104
- warnOnce(nextValue.version === "11.2.7", `Attempting to mix Framer Motion versions ${nextValue.version} with 11.2.7 may not work as expected.`);
7105
+ warnOnce(nextValue.version === "11.2.8", `Attempting to mix Framer Motion versions ${nextValue.version} with 11.2.8 may not work as expected.`);
7105
7106
  }
7106
7107
  }
7107
7108
  else if (isMotionValue(prevValue)) {