motion 14.7.1 → 14.8.0
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/cjs/remix.js +14 -0
- package/dist/es/remix.mjs +1 -0
- package/dist/motion.dev.js +406 -154
- package/dist/motion.js +1 -1
- package/dist/remix.d.ts +1 -0
- package/package.json +15 -4
- package/remix/package.json +6 -0
package/dist/motion.dev.js
CHANGED
|
@@ -1619,10 +1619,11 @@
|
|
|
1619
1619
|
|
|
1620
1620
|
function createMixers(output, ease, customMixer) {
|
|
1621
1621
|
const mixers = [];
|
|
1622
|
-
const mixerFactory =
|
|
1622
|
+
const mixerFactory = MotionGlobalConfig.mix || mix;
|
|
1623
1623
|
const numMixers = output.length - 1;
|
|
1624
1624
|
for (let i = 0; i < numMixers; i++) {
|
|
1625
|
-
let mixer =
|
|
1625
|
+
let mixer = customMixer?.(output[i], output[i + 1]) ||
|
|
1626
|
+
mixerFactory(output[i], output[i + 1]);
|
|
1626
1627
|
if (ease) {
|
|
1627
1628
|
const easingFunction = Array.isArray(ease) ? ease[i] || noop : ease;
|
|
1628
1629
|
mixer = pipe(easingFunction, mixer);
|
|
@@ -1708,7 +1709,13 @@
|
|
|
1708
1709
|
function defaultEasing(values, easing) {
|
|
1709
1710
|
return values.map(() => easing || easeInOut).splice(0, values.length - 1);
|
|
1710
1711
|
}
|
|
1711
|
-
function keyframes({ duration = 300, keyframes: keyframeValues, times, ease = "easeInOut", }) {
|
|
1712
|
+
function keyframes({ duration = 300, keyframes: keyframeValues, times, ease = "easeInOut", mixer: transitionMixer, }) {
|
|
1713
|
+
/**
|
|
1714
|
+
* A mixer only blends values that aren't numbers. Numbers blend as
|
|
1715
|
+
* usual, as they do in springs, and so do the progress animations
|
|
1716
|
+
* behind layout and path animations, which take the same transition.
|
|
1717
|
+
*/
|
|
1718
|
+
const customMixer = typeof keyframeValues[0] === "number" ? undefined : transitionMixer;
|
|
1712
1719
|
/**
|
|
1713
1720
|
* Easing functions can be externally defined as strings. Here we convert them
|
|
1714
1721
|
* into actual functions.
|
|
@@ -1725,9 +1732,11 @@
|
|
|
1725
1732
|
value: keyframeValues[0],
|
|
1726
1733
|
};
|
|
1727
1734
|
/**
|
|
1728
|
-
* Fast setup path for two keyframes one easing.
|
|
1735
|
+
* Fast setup path for two keyframes one easing. interpolate() handles
|
|
1736
|
+
* a custom mixer, and falls back to the usual one where it declines.
|
|
1729
1737
|
*/
|
|
1730
|
-
if (
|
|
1738
|
+
if (!customMixer &&
|
|
1739
|
+
keyframeValues.length === 2 &&
|
|
1731
1740
|
!Array.isArray(easingFunctions) &&
|
|
1732
1741
|
(!times ||
|
|
1733
1742
|
times.length !== 2 ||
|
|
@@ -1760,6 +1769,7 @@
|
|
|
1760
1769
|
ease: Array.isArray(easingFunctions)
|
|
1761
1770
|
? easingFunctions
|
|
1762
1771
|
: defaultEasing(keyframeValues, easingFunctions),
|
|
1772
|
+
mixer: customMixer,
|
|
1763
1773
|
});
|
|
1764
1774
|
return {
|
|
1765
1775
|
calculatedDuration: duration,
|
|
@@ -1967,9 +1977,15 @@
|
|
|
1967
1977
|
if (generatorFactory !== keyframes) {
|
|
1968
1978
|
exports.invariant(keyframes$1.length <= 2, `Only two keyframes currently supported with spring and inertia animations. Trying to animate ${keyframes$1}`, "spring-two-frames");
|
|
1969
1979
|
}
|
|
1980
|
+
/**
|
|
1981
|
+
* This runs again when a spring is flattened to attach it to a
|
|
1982
|
+
* timeline, and the keyframes generator blends values itself.
|
|
1983
|
+
*/
|
|
1984
|
+
this.mixKeyframes = undefined;
|
|
1970
1985
|
if (generatorFactory !== keyframes &&
|
|
1971
1986
|
typeof keyframes$1[0] !== "number") {
|
|
1972
|
-
this.mixKeyframes = pipe(percentToProgress,
|
|
1987
|
+
this.mixKeyframes = pipe(percentToProgress, options.mixer?.(keyframes$1[0], keyframes$1[1]) ||
|
|
1988
|
+
mix(keyframes$1[0], keyframes$1[1]));
|
|
1973
1989
|
keyframes$1 = [0, 100];
|
|
1974
1990
|
}
|
|
1975
1991
|
const generator = generatorFactory(keyframes$1 === options.keyframes
|
|
@@ -3323,6 +3339,15 @@
|
|
|
3323
3339
|
return false;
|
|
3324
3340
|
}
|
|
3325
3341
|
|
|
3342
|
+
/**
|
|
3343
|
+
* Whether an animation needs its mixer, which WAAPI can't call. Numbers
|
|
3344
|
+
* blend as usual, and an animation whose mixer declines every pair runs
|
|
3345
|
+
* as it would without one.
|
|
3346
|
+
*/
|
|
3347
|
+
const needsMixer = ({ mixer, keyframes }) => mixer &&
|
|
3348
|
+
typeof keyframes[0] !== "number" &&
|
|
3349
|
+
keyframes.some((keyframe, i) => i && mixer(keyframes[i - 1], keyframe));
|
|
3350
|
+
|
|
3326
3351
|
const colorProperties = new Set([
|
|
3327
3352
|
"color",
|
|
3328
3353
|
"backgroundColor",
|
|
@@ -3382,7 +3407,8 @@
|
|
|
3382
3407
|
!repeatDelay &&
|
|
3383
3408
|
repeatType !== "mirror" &&
|
|
3384
3409
|
damping !== 0 &&
|
|
3385
|
-
type !== "inertia"
|
|
3410
|
+
type !== "inertia" &&
|
|
3411
|
+
!needsMixer(options));
|
|
3386
3412
|
}
|
|
3387
3413
|
|
|
3388
3414
|
/**
|
|
@@ -3481,18 +3507,21 @@
|
|
|
3481
3507
|
* Named easings that are the same cubic-bezier in JS and CSS.
|
|
3482
3508
|
*/
|
|
3483
3509
|
const isNativeEasing = (ease) => /^(linear|ease(In|Out|InOut))$/.test(ease);
|
|
3510
|
+
/**
|
|
3511
|
+
* Whether two eased progresses match. False if either is NaN.
|
|
3512
|
+
*/
|
|
3513
|
+
const isNear$1 = (a, b) => Math.abs(a - b) <= easingTolerance;
|
|
3484
3514
|
const byTime = (a, b) => a - b;
|
|
3485
3515
|
/**
|
|
3486
3516
|
* n + 1 evenly spaced timestamps, from one timestamp to another.
|
|
3487
3517
|
*/
|
|
3488
|
-
const spread = (from, to, n) =>
|
|
3489
|
-
const result = [];
|
|
3490
|
-
for (let i = 0; i <= n; i++)
|
|
3491
|
-
result.push(mixNumber$1(from, to, i / n));
|
|
3492
|
-
return result;
|
|
3493
|
-
};
|
|
3518
|
+
const spread = (from, to, n) => defaultOffset$1(Array(n + 1)).map((p) => mixNumber$1(from, to, p));
|
|
3494
3519
|
const getOwner = (options) => options.motionValue.owner;
|
|
3495
3520
|
const getGroup = (element) => transformGroups.get(element);
|
|
3521
|
+
/**
|
|
3522
|
+
* Whether an animation has ended, so can leave its group.
|
|
3523
|
+
*/
|
|
3524
|
+
const hasEnded = ({ state }) => state === "idle" || state === "finished";
|
|
3496
3525
|
const read = (owner, key) => owner.latestValues ? owner.latestValues[key] : owner.getValue(key)?.get();
|
|
3497
3526
|
/**
|
|
3498
3527
|
* Whether this animation should join its element's transform group.
|
|
@@ -3531,7 +3560,12 @@
|
|
|
3531
3560
|
/**
|
|
3532
3561
|
* Layout animations write transform every frame.
|
|
3533
3562
|
*/
|
|
3534
|
-
!owner.projection?.isProjecting()
|
|
3563
|
+
!owner.projection?.isProjecting() &&
|
|
3564
|
+
/**
|
|
3565
|
+
* A mixer that blends these values makes them every frame. It's
|
|
3566
|
+
* asked last, as it's user code.
|
|
3567
|
+
*/
|
|
3568
|
+
!needsMixer(options));
|
|
3535
3569
|
}
|
|
3536
3570
|
class TransformAnimation extends JSAnimation {
|
|
3537
3571
|
constructor(options) {
|
|
@@ -3888,9 +3922,8 @@
|
|
|
3888
3922
|
let shared;
|
|
3889
3923
|
let progressAt;
|
|
3890
3924
|
for (const track of moving) {
|
|
3891
|
-
const
|
|
3892
|
-
const
|
|
3893
|
-
const changes = values.map((value) => value - first);
|
|
3925
|
+
const first = track.numberAt(from);
|
|
3926
|
+
const changes = at.map((t) => track.numberAt(t) - first);
|
|
3894
3927
|
const end = changes[changes.length - 1];
|
|
3895
3928
|
/**
|
|
3896
3929
|
* A value that ends only a tiny way from where it started, as
|
|
@@ -3904,25 +3937,20 @@
|
|
|
3904
3937
|
: end;
|
|
3905
3938
|
const progress = changes.map((change) => range ? change / range : change);
|
|
3906
3939
|
/**
|
|
3907
|
-
*
|
|
3908
|
-
*
|
|
3909
|
-
* fits
|
|
3940
|
+
* The first value that moves sets the easing, and every other
|
|
3941
|
+
* one must follow it. A value that doesn't change, like one
|
|
3942
|
+
* still in its delay, fits any easing. One that changes but
|
|
3943
|
+
* ends where it started fits none.
|
|
3910
3944
|
*/
|
|
3911
|
-
if (!
|
|
3912
|
-
if (progress.some((p) => !(Math.abs(p) <= easingTolerance))) {
|
|
3913
|
-
return;
|
|
3914
|
-
}
|
|
3915
|
-
}
|
|
3916
|
-
else if (!shared) {
|
|
3945
|
+
if (range && !shared) {
|
|
3917
3946
|
shared = progress;
|
|
3918
3947
|
progressAt = (t) => (track.numberAt(t) - first) / range;
|
|
3919
3948
|
}
|
|
3920
|
-
else if (progress.some((p, i) => !(
|
|
3949
|
+
else if (progress.some((p, i) => !isNear$1(p, range && shared[i]))) {
|
|
3921
3950
|
return;
|
|
3922
3951
|
}
|
|
3923
3952
|
}
|
|
3924
|
-
if (!shared ||
|
|
3925
|
-
shared.every((p, i) => Math.abs(p - position(at[i])) <= easingTolerance)) {
|
|
3953
|
+
if (!shared || shared.every((p, i) => isNear$1(p, position(at[i])))) {
|
|
3926
3954
|
return "linear";
|
|
3927
3955
|
}
|
|
3928
3956
|
/**
|
|
@@ -4009,7 +4037,7 @@
|
|
|
4009
4037
|
/**
|
|
4010
4038
|
* A WAAPI animation of the composed transform between two timestamps.
|
|
4011
4039
|
*/
|
|
4012
|
-
const run = (moving, from, to, options = { fill: "both" }, settled
|
|
4040
|
+
const run = (moving, from, to, nativeEasing, options = { fill: "both" }, settled) => {
|
|
4013
4041
|
const bounds = moving.flatMap((track) => track.boundaries(from, to));
|
|
4014
4042
|
const easing = nativeEasing || getEasing(moving, from, to, bounds);
|
|
4015
4043
|
const times = easing ? [from, to] : sample(moving, from, to, bounds);
|
|
@@ -4095,9 +4123,7 @@
|
|
|
4095
4123
|
if (byKey.has(key))
|
|
4096
4124
|
return true;
|
|
4097
4125
|
const value = (statics[key] = read(owner, key));
|
|
4098
|
-
return
|
|
4099
|
-
parseFloat(value) !==
|
|
4100
|
-
(key.startsWith("scale") ? 1 : 0));
|
|
4126
|
+
return value !== undefined && !isDefaultTransform(key, value);
|
|
4101
4127
|
});
|
|
4102
4128
|
stop(false);
|
|
4103
4129
|
/**
|
|
@@ -4108,7 +4134,7 @@
|
|
|
4108
4134
|
try {
|
|
4109
4135
|
if (tween && tween[1] > now) {
|
|
4110
4136
|
const [from, to, easing] = tween;
|
|
4111
|
-
add(run(moving, from, to,
|
|
4137
|
+
add(run(moving, from, to, easing), from - now, to - from);
|
|
4112
4138
|
}
|
|
4113
4139
|
else if (end > now) {
|
|
4114
4140
|
add(run(moving, now, end), 0, end - now);
|
|
@@ -4125,7 +4151,7 @@
|
|
|
4125
4151
|
* seamlessly, and start it part way through.
|
|
4126
4152
|
*/
|
|
4127
4153
|
const from = cycleStart + Math.floor((end - cycleStart) / cycle) * cycle;
|
|
4128
|
-
add(run(looping, from, from + cycle, {
|
|
4154
|
+
add(run(looping, from, from + cycle, undefined, {
|
|
4129
4155
|
iterations: Infinity,
|
|
4130
4156
|
iterationStart: (end - from) / cycle,
|
|
4131
4157
|
/**
|
|
@@ -4264,10 +4290,7 @@
|
|
|
4264
4290
|
isScheduled = false;
|
|
4265
4291
|
if (isEnded)
|
|
4266
4292
|
return;
|
|
4267
|
-
tracks.forEach((
|
|
4268
|
-
if (state === "idle" || state === "finished")
|
|
4269
|
-
tracks.delete(track);
|
|
4270
|
-
});
|
|
4293
|
+
tracks.forEach((track) => hasEnded(track) && tracks.delete(track));
|
|
4271
4294
|
if (end())
|
|
4272
4295
|
return;
|
|
4273
4296
|
for (const track of tracks) {
|
|
@@ -4327,9 +4350,7 @@
|
|
|
4327
4350
|
* Only drop the stopped animation. Others can be idle because
|
|
4328
4351
|
* they're part way through play(), and are about to run.
|
|
4329
4352
|
*/
|
|
4330
|
-
|
|
4331
|
-
if (state === "idle" || state === "finished")
|
|
4332
|
-
tracks.delete(track);
|
|
4353
|
+
hasEnded(track) && tracks.delete(track);
|
|
4333
4354
|
end() || group.schedule(true);
|
|
4334
4355
|
},
|
|
4335
4356
|
/**
|
|
@@ -4886,10 +4907,19 @@
|
|
|
4886
4907
|
* effects, and resets velocity to `0`.
|
|
4887
4908
|
*/
|
|
4888
4909
|
jump(v, endAnimation = true) {
|
|
4910
|
+
if (endAnimation) {
|
|
4911
|
+
/**
|
|
4912
|
+
* Stop first, as stopping a running animation can set the
|
|
4913
|
+
* value it's showing, which would replace v. Marking the value
|
|
4914
|
+
* as updated now skips a JS animation's catch-up tick on stop,
|
|
4915
|
+
* which could otherwise complete it.
|
|
4916
|
+
*/
|
|
4917
|
+
this.updatedAt = time.now();
|
|
4918
|
+
this.stop();
|
|
4919
|
+
}
|
|
4889
4920
|
this.updateAndNotify(v);
|
|
4890
4921
|
this.prev = v;
|
|
4891
4922
|
this.prevUpdatedAt = this.prevFrameValue = undefined;
|
|
4892
|
-
endAnimation && this.stop();
|
|
4893
4923
|
this.stopPassiveEffect?.();
|
|
4894
4924
|
}
|
|
4895
4925
|
dirty() {
|
|
@@ -5108,6 +5138,7 @@
|
|
|
5108
5138
|
"from",
|
|
5109
5139
|
"elapsed",
|
|
5110
5140
|
"out",
|
|
5141
|
+
"mixer",
|
|
5111
5142
|
]);
|
|
5112
5143
|
/**
|
|
5113
5144
|
* Decide whether a transition is defined on a given Transition.
|
|
@@ -6664,6 +6695,20 @@
|
|
|
6664
6695
|
else if (key.startsWith("attr")) {
|
|
6665
6696
|
return addAttrValue(element, state, key, value, convertAttrKey(key));
|
|
6666
6697
|
}
|
|
6698
|
+
else if (key === "d") {
|
|
6699
|
+
/**
|
|
6700
|
+
* `d` is a CSS property in Chrome and Firefox, but only as
|
|
6701
|
+
* `path(...)`, so path data goes to the attribute, taken out of
|
|
6702
|
+
* `path(...)` if it's written that way. Path data itself has no
|
|
6703
|
+
* quotes or brackets.
|
|
6704
|
+
*/
|
|
6705
|
+
return state.set(key, value, () => {
|
|
6706
|
+
const d = value.get()?.replace(/path\(|["')]/g, "");
|
|
6707
|
+
d === undefined
|
|
6708
|
+
? element.removeAttribute(key)
|
|
6709
|
+
: element.setAttribute(key, d);
|
|
6710
|
+
});
|
|
6711
|
+
}
|
|
6667
6712
|
/**
|
|
6668
6713
|
* Transforms and origins aren't CSS properties (bar `x`/`y` in some
|
|
6669
6714
|
* browsers), so check them by name rather than `key in element.style`.
|
|
@@ -6920,6 +6965,10 @@
|
|
|
6920
6965
|
}
|
|
6921
6966
|
return viewportBox;
|
|
6922
6967
|
}
|
|
6968
|
+
const measureDocumentScroll = () => ({
|
|
6969
|
+
x: document.documentElement.scrollLeft || document.body?.scrollLeft || 0,
|
|
6970
|
+
y: document.documentElement.scrollTop || document.body?.scrollTop || 0,
|
|
6971
|
+
});
|
|
6923
6972
|
|
|
6924
6973
|
const noProps = {};
|
|
6925
6974
|
const getElementEffect = (element) => (isSVGElement(element)
|
|
@@ -7089,6 +7138,7 @@
|
|
|
7089
7138
|
const statsBuffer = {
|
|
7090
7139
|
value: null,
|
|
7091
7140
|
addProjectionMetrics: null,
|
|
7141
|
+
countProjection: undefined,
|
|
7092
7142
|
};
|
|
7093
7143
|
|
|
7094
7144
|
/**
|
|
@@ -7111,6 +7161,12 @@
|
|
|
7111
7161
|
return delay(callback, secondsToMilliseconds(timeout));
|
|
7112
7162
|
}
|
|
7113
7163
|
|
|
7164
|
+
function isRefObject(ref) {
|
|
7165
|
+
return (ref &&
|
|
7166
|
+
typeof ref === "object" &&
|
|
7167
|
+
Object.prototype.hasOwnProperty.call(ref, "current"));
|
|
7168
|
+
}
|
|
7169
|
+
|
|
7114
7170
|
/**
|
|
7115
7171
|
* Checks if an element is specifically an SVGSVGElement (the root SVG element)
|
|
7116
7172
|
* in a way that works across iframes
|
|
@@ -7325,6 +7381,27 @@
|
|
|
7325
7381
|
removeAxisTransforms(box.y, transforms, yKeys, originBox?.y, sourceBox?.y);
|
|
7326
7382
|
}
|
|
7327
7383
|
|
|
7384
|
+
const userAgentContains = (string) => typeof navigator !== "undefined" &&
|
|
7385
|
+
navigator.userAgent &&
|
|
7386
|
+
navigator.userAgent.toLowerCase().includes(string);
|
|
7387
|
+
/**
|
|
7388
|
+
* Measured bounding boxes must be rounded in Safari and
|
|
7389
|
+
* left untouched in Chrome, otherwise non-integer layouts within scaled-up elements
|
|
7390
|
+
* can appear to jump.
|
|
7391
|
+
*/
|
|
7392
|
+
const roundPoint = userAgentContains("applewebkit/") && !userAgentContains("chrome/")
|
|
7393
|
+
? Math.round
|
|
7394
|
+
: noop;
|
|
7395
|
+
function roundAxis(axis) {
|
|
7396
|
+
// Round to the nearest .5 pixels to support subpixel layouts
|
|
7397
|
+
axis.min = roundPoint(axis.min);
|
|
7398
|
+
axis.max = roundPoint(axis.max);
|
|
7399
|
+
}
|
|
7400
|
+
function roundBox(box) {
|
|
7401
|
+
roundAxis(box.x);
|
|
7402
|
+
roundAxis(box.y);
|
|
7403
|
+
}
|
|
7404
|
+
|
|
7328
7405
|
const createAxisDelta = () => ({
|
|
7329
7406
|
translate: 0,
|
|
7330
7407
|
scale: 1,
|
|
@@ -7621,11 +7698,6 @@
|
|
|
7621
7698
|
hasEverUpdated: false,
|
|
7622
7699
|
};
|
|
7623
7700
|
|
|
7624
|
-
const metrics = {
|
|
7625
|
-
nodes: 0,
|
|
7626
|
-
calculatedTargetDeltas: 0,
|
|
7627
|
-
calculatedProjections: 0,
|
|
7628
|
-
};
|
|
7629
7701
|
/**
|
|
7630
7702
|
* Transforms that distort an element's layout, so must be reset before measuring.
|
|
7631
7703
|
*/
|
|
@@ -7673,6 +7745,13 @@
|
|
|
7673
7745
|
cancelTreeOptimisedTransformAnimations(parent);
|
|
7674
7746
|
}
|
|
7675
7747
|
}
|
|
7748
|
+
function getClosestProjectingNode(visualElement) {
|
|
7749
|
+
if (!visualElement)
|
|
7750
|
+
return undefined;
|
|
7751
|
+
return visualElement.options.allowProjection !== false
|
|
7752
|
+
? visualElement.projection
|
|
7753
|
+
: getClosestProjectingNode(visualElement.parent);
|
|
7754
|
+
}
|
|
7676
7755
|
function createProjectionNode({ attachResizeListener, defaultParent, measureScroll, checkIsScrollRoot, resetTransform, }) {
|
|
7677
7756
|
/**
|
|
7678
7757
|
* Correctors registered via addScaleCorrector before projection loaded
|
|
@@ -7685,6 +7764,57 @@
|
|
|
7685
7764
|
...scaleCorrectors,
|
|
7686
7765
|
});
|
|
7687
7766
|
return class ProjectionNode {
|
|
7767
|
+
/**
|
|
7768
|
+
* Create the projection node of a `motion` component's VisualElement,
|
|
7769
|
+
* from its props. This runs while the component renders, before its
|
|
7770
|
+
* children. It's here rather than in the component so React
|
|
7771
|
+
* bundles only include it with the features that supply a
|
|
7772
|
+
* ProjectionNode. Vanilla bundles that use the projection node
|
|
7773
|
+
* (drag(), animateLayout()) include it too, as a class static
|
|
7774
|
+
* can't be tree-shaken.
|
|
7775
|
+
*/
|
|
7776
|
+
static create(visualElement, props, initialPromotionConfig) {
|
|
7777
|
+
const { layoutId, layout, drag, dragConstraints, layoutScroll, layoutRoot, layoutAnchor, layoutCrossfade, } = props;
|
|
7778
|
+
const projection = (visualElement.projection = new this(visualElement.latestValues, props["data-framer-portal-id"]
|
|
7779
|
+
? undefined
|
|
7780
|
+
: getClosestProjectingNode(visualElement.parent)));
|
|
7781
|
+
projection.setOptions({
|
|
7782
|
+
layoutId,
|
|
7783
|
+
layout,
|
|
7784
|
+
alwaysMeasureLayout: Boolean(drag) ||
|
|
7785
|
+
(dragConstraints && isRefObject(dragConstraints)),
|
|
7786
|
+
visualElement,
|
|
7787
|
+
/**
|
|
7788
|
+
* TODO: Update options in an effect. This could be tricky as it'll be too late
|
|
7789
|
+
* to update by the time layout animations run.
|
|
7790
|
+
* We also need to fix this safeToRemove by linking it up to the one returned by usePresence,
|
|
7791
|
+
* ensuring it gets called if there's no potential layout animations.
|
|
7792
|
+
*
|
|
7793
|
+
*/
|
|
7794
|
+
animationType: typeof layout === "string" ? layout : "both",
|
|
7795
|
+
initialPromotionConfig,
|
|
7796
|
+
crossfade: layoutCrossfade,
|
|
7797
|
+
layoutScroll,
|
|
7798
|
+
layoutRoot,
|
|
7799
|
+
layoutAnchor,
|
|
7800
|
+
});
|
|
7801
|
+
/**
|
|
7802
|
+
* This node will take over from its layoutId's current lead, so snapshot
|
|
7803
|
+
* the lead now, while rendering. By the time the lead unmounts (or this
|
|
7804
|
+
* node mounts) React may already have committed DOM changes that come
|
|
7805
|
+
* before it in the tree, like a sibling changing height, and a snapshot
|
|
7806
|
+
* taken then starts the animation from a position never seen on screen.
|
|
7807
|
+
*
|
|
7808
|
+
* If React discards this render (e.g. it suspends), nothing else
|
|
7809
|
+
* completes the update, so check it after the next frame as an
|
|
7810
|
+
* unmounting node does.
|
|
7811
|
+
*/
|
|
7812
|
+
const lead = projection.getStack()?.lead;
|
|
7813
|
+
if (lead && !projection.root.isUpdateBlocked()) {
|
|
7814
|
+
lead.willUpdate();
|
|
7815
|
+
lead.scheduleCheckAfterUnmount();
|
|
7816
|
+
}
|
|
7817
|
+
}
|
|
7688
7818
|
constructor(latestValues = {}, parent = defaultParent?.()) {
|
|
7689
7819
|
/**
|
|
7690
7820
|
* A unique ID generated for every projection node.
|
|
@@ -7797,23 +7927,14 @@
|
|
|
7797
7927
|
*/
|
|
7798
7928
|
this.updateProjection = () => {
|
|
7799
7929
|
this.projectionUpdateScheduled = false;
|
|
7800
|
-
/**
|
|
7801
|
-
* Reset debug counts. Manually resetting rather than creating a new
|
|
7802
|
-
* object each frame.
|
|
7803
|
-
*/
|
|
7804
|
-
if (statsBuffer.value) {
|
|
7805
|
-
metrics.nodes =
|
|
7806
|
-
metrics.calculatedTargetDeltas =
|
|
7807
|
-
metrics.calculatedProjections =
|
|
7808
|
-
0;
|
|
7809
|
-
}
|
|
7810
7930
|
this.nodes.forEach(propagateDirtyNodes);
|
|
7811
7931
|
this.nodes.forEach(resolveTargetDelta);
|
|
7812
7932
|
this.nodes.forEach(calcProjection);
|
|
7813
7933
|
this.nodes.forEach(cleanDirtyNodes);
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7934
|
+
/**
|
|
7935
|
+
* Record this frame's debug counts, if recordStats() is running.
|
|
7936
|
+
*/
|
|
7937
|
+
statsBuffer.countProjection?.();
|
|
7817
7938
|
};
|
|
7818
7939
|
/**
|
|
7819
7940
|
* Frame calculations
|
|
@@ -8529,9 +8650,7 @@
|
|
|
8529
8650
|
/**
|
|
8530
8651
|
* Increase debug counter for resolved target deltas
|
|
8531
8652
|
*/
|
|
8532
|
-
|
|
8533
|
-
metrics.calculatedTargetDeltas++;
|
|
8534
|
-
}
|
|
8653
|
+
statsBuffer.countProjection?.(1); // calculatedTargetDeltas
|
|
8535
8654
|
}
|
|
8536
8655
|
getClosestProjectingParent() {
|
|
8537
8656
|
if (!this.parent ||
|
|
@@ -8679,9 +8798,7 @@
|
|
|
8679
8798
|
/**
|
|
8680
8799
|
* Increase debug counter for recalculated projections
|
|
8681
8800
|
*/
|
|
8682
|
-
|
|
8683
|
-
metrics.calculatedProjections++;
|
|
8684
|
-
}
|
|
8801
|
+
statsBuffer.countProjection?.(2); // calculatedProjections
|
|
8685
8802
|
}
|
|
8686
8803
|
hide() {
|
|
8687
8804
|
this.isVisible = false;
|
|
@@ -9208,9 +9325,7 @@
|
|
|
9208
9325
|
/**
|
|
9209
9326
|
* Increase debug counter for nodes encountered this frame
|
|
9210
9327
|
*/
|
|
9211
|
-
|
|
9212
|
-
metrics.nodes++;
|
|
9213
|
-
}
|
|
9328
|
+
statsBuffer.countProjection?.(0); // nodes
|
|
9214
9329
|
if (!node.parent)
|
|
9215
9330
|
return;
|
|
9216
9331
|
/**
|
|
@@ -9341,26 +9456,6 @@
|
|
|
9341
9456
|
duration: 0.45,
|
|
9342
9457
|
ease: [0.4, 0, 0.1, 1],
|
|
9343
9458
|
};
|
|
9344
|
-
const userAgentContains = (string) => typeof navigator !== "undefined" &&
|
|
9345
|
-
navigator.userAgent &&
|
|
9346
|
-
navigator.userAgent.toLowerCase().includes(string);
|
|
9347
|
-
/**
|
|
9348
|
-
* Measured bounding boxes must be rounded in Safari and
|
|
9349
|
-
* left untouched in Chrome, otherwise non-integer layouts within scaled-up elements
|
|
9350
|
-
* can appear to jump.
|
|
9351
|
-
*/
|
|
9352
|
-
const roundPoint = userAgentContains("applewebkit/") && !userAgentContains("chrome/")
|
|
9353
|
-
? Math.round
|
|
9354
|
-
: noop;
|
|
9355
|
-
function roundAxis(axis) {
|
|
9356
|
-
// Round to the nearest .5 pixels to support subpixel layouts
|
|
9357
|
-
axis.min = roundPoint(axis.min);
|
|
9358
|
-
axis.max = roundPoint(axis.max);
|
|
9359
|
-
}
|
|
9360
|
-
function roundBox(box) {
|
|
9361
|
-
roundAxis(box.x);
|
|
9362
|
-
roundAxis(box.y);
|
|
9363
|
-
}
|
|
9364
9459
|
/**
|
|
9365
9460
|
* Align an axis to the start of another, keeping the length of a layout axis.
|
|
9366
9461
|
* The length is read first, as output can be the layout axis itself.
|
|
@@ -9385,14 +9480,7 @@
|
|
|
9385
9480
|
const DocumentProjectionNode =
|
|
9386
9481
|
/* @__PURE__ */ createProjectionNode({
|
|
9387
9482
|
attachResizeListener: (ref, notify) => addDomEvent(ref, "resize", notify),
|
|
9388
|
-
measureScroll:
|
|
9389
|
-
x: document.documentElement.scrollLeft ||
|
|
9390
|
-
document.body?.scrollLeft ||
|
|
9391
|
-
0,
|
|
9392
|
-
y: document.documentElement.scrollTop ||
|
|
9393
|
-
document.body?.scrollTop ||
|
|
9394
|
-
0,
|
|
9395
|
-
}),
|
|
9483
|
+
measureScroll: measureDocumentScroll,
|
|
9396
9484
|
checkIsScrollRoot: () => true,
|
|
9397
9485
|
});
|
|
9398
9486
|
|
|
@@ -10165,6 +10253,124 @@
|
|
|
10165
10253
|
}
|
|
10166
10254
|
}
|
|
10167
10255
|
|
|
10256
|
+
/**
|
|
10257
|
+
* Get the VisualElement that imperative APIs like animateLayout() and
|
|
10258
|
+
* drag() render an element with, creating one if it has none, ready for
|
|
10259
|
+
* a projection node to be attached.
|
|
10260
|
+
*/
|
|
10261
|
+
function resolveVisualElement(element) {
|
|
10262
|
+
let visualElement = visualElementStore.get(element);
|
|
10263
|
+
if (!visualElement) {
|
|
10264
|
+
visualElement = new HTMLVisualElement({
|
|
10265
|
+
props: {},
|
|
10266
|
+
presenceContext: null,
|
|
10267
|
+
visualState: {
|
|
10268
|
+
latestValues: {},
|
|
10269
|
+
renderState: {
|
|
10270
|
+
transform: {},
|
|
10271
|
+
transformOrigin: {},
|
|
10272
|
+
style: {},
|
|
10273
|
+
vars: {},
|
|
10274
|
+
},
|
|
10275
|
+
},
|
|
10276
|
+
}, { allowProjection: true });
|
|
10277
|
+
/**
|
|
10278
|
+
* Values animate() has been rendering on this element move to
|
|
10279
|
+
* the VisualElement, so the layout animation composes with
|
|
10280
|
+
* them instead of overwriting them.
|
|
10281
|
+
*/
|
|
10282
|
+
handOffElementState(element, visualElement);
|
|
10283
|
+
}
|
|
10284
|
+
/**
|
|
10285
|
+
* A first-time element may carry a projection transform in its
|
|
10286
|
+
* inline style (e.g. it was cloned from an element mid-animation).
|
|
10287
|
+
* That transform isn't tracked in latestValues so the engine can't
|
|
10288
|
+
* reset it before measuring - clear it now so the first layout
|
|
10289
|
+
* measurement isn't inflated.
|
|
10290
|
+
*/
|
|
10291
|
+
if (element.style.transform && !hasTransform(visualElement.latestValues)) {
|
|
10292
|
+
element.style.transform = "";
|
|
10293
|
+
}
|
|
10294
|
+
return visualElement;
|
|
10295
|
+
}
|
|
10296
|
+
|
|
10297
|
+
/**
|
|
10298
|
+
* animateLayout() registers a function here that creates nodes in the
|
|
10299
|
+
* layout projection tree. When it's in the bundle, drag() uses those, so
|
|
10300
|
+
* the two work together (e.g. a drag follows a layout change mid-gesture).
|
|
10301
|
+
* Otherwise drag() makes do with a node that only measures. Bundles that
|
|
10302
|
+
* don't tree-shake (dev pre-bundling, CDN builds) always register it, and
|
|
10303
|
+
* a drag() started before animateLayout() is lazy loaded keeps its node.
|
|
10304
|
+
*/
|
|
10305
|
+
const layoutProjection = {};
|
|
10306
|
+
/**
|
|
10307
|
+
* The document root of measurement-only nodes. Like the projection tree's
|
|
10308
|
+
* root, it keeps its scroll until drag controls clear it to re-measure.
|
|
10309
|
+
*/
|
|
10310
|
+
const root = {
|
|
10311
|
+
updateScroll: () => {
|
|
10312
|
+
root.scroll || (root.scroll = { offset: measureDocumentScroll() });
|
|
10313
|
+
},
|
|
10314
|
+
};
|
|
10315
|
+
/**
|
|
10316
|
+
* The part of a projection node that drag controls use: measuring the
|
|
10317
|
+
* element's page box, for its layout and constraints. It never projects
|
|
10318
|
+
* or joins a layout update.
|
|
10319
|
+
*/
|
|
10320
|
+
const createMeasureNode = (element) => {
|
|
10321
|
+
const visualElement = resolveVisualElement(element);
|
|
10322
|
+
const measureListeners = new SubscriptionManager();
|
|
10323
|
+
const node = {
|
|
10324
|
+
instance: element,
|
|
10325
|
+
root,
|
|
10326
|
+
path: [root],
|
|
10327
|
+
setOptions: noop,
|
|
10328
|
+
/**
|
|
10329
|
+
* Truthy like the full node's method, which HTMLVisualElement reads
|
|
10330
|
+
* (rather than calls) to default transform values.
|
|
10331
|
+
*/
|
|
10332
|
+
isProjecting: noop,
|
|
10333
|
+
applyProjectionStyles: noop,
|
|
10334
|
+
removeElementScroll: (box) => box,
|
|
10335
|
+
updateLayout: () => {
|
|
10336
|
+
const layoutBox = measurePageBox(element, root, visualElement.getTransformPagePoint());
|
|
10337
|
+
roundBox(layoutBox);
|
|
10338
|
+
node.layout = { layoutBox };
|
|
10339
|
+
measureListeners.notify();
|
|
10340
|
+
},
|
|
10341
|
+
addEventListener: (name, handler) => name === "measure" ? measureListeners.add(handler) : noop,
|
|
10342
|
+
/**
|
|
10343
|
+
* Detach from the VisualElement too, so it doesn't later remount
|
|
10344
|
+
* (or a `motion` component's layout feature adopt) a node that
|
|
10345
|
+
* can't do either.
|
|
10346
|
+
*/
|
|
10347
|
+
unmount: () => {
|
|
10348
|
+
node.instance = undefined;
|
|
10349
|
+
if (visualElement.projection === node) {
|
|
10350
|
+
visualElement.projection = undefined;
|
|
10351
|
+
}
|
|
10352
|
+
},
|
|
10353
|
+
};
|
|
10354
|
+
visualElement.projection = node;
|
|
10355
|
+
visualElement.current || visualElement.mount(element);
|
|
10356
|
+
return [node, node.unmount];
|
|
10357
|
+
};
|
|
10358
|
+
/**
|
|
10359
|
+
* Get a projection node for drag() to measure an element with, and a
|
|
10360
|
+
* function that releases it. Reuses a node a `motion` component or
|
|
10361
|
+
* animateLayout() owns.
|
|
10362
|
+
*/
|
|
10363
|
+
const acquireDragNode = (element) => {
|
|
10364
|
+
const owned = visualElementStore.get(element)?.projection;
|
|
10365
|
+
/**
|
|
10366
|
+
* A VisualElement can outlive its node (e.g. an unmounted `motion`
|
|
10367
|
+
* component's), so only reuse a node that's still mounted.
|
|
10368
|
+
*/
|
|
10369
|
+
return owned?.instance
|
|
10370
|
+
? [owned, noop]
|
|
10371
|
+
: (layoutProjection.create || createMeasureNode)(element);
|
|
10372
|
+
};
|
|
10373
|
+
|
|
10168
10374
|
const layoutSelector = "[data-layout],[data-layout-id]";
|
|
10169
10375
|
/**
|
|
10170
10376
|
* All imperatively-created projection nodes live in one persistent tree,
|
|
@@ -10217,21 +10423,6 @@
|
|
|
10217
10423
|
}
|
|
10218
10424
|
return undefined;
|
|
10219
10425
|
}
|
|
10220
|
-
function createVisualElement() {
|
|
10221
|
-
return new HTMLVisualElement({
|
|
10222
|
-
props: {},
|
|
10223
|
-
presenceContext: null,
|
|
10224
|
-
visualState: {
|
|
10225
|
-
latestValues: {},
|
|
10226
|
-
renderState: {
|
|
10227
|
-
transform: {},
|
|
10228
|
-
transformOrigin: {},
|
|
10229
|
-
style: {},
|
|
10230
|
-
vars: {},
|
|
10231
|
-
},
|
|
10232
|
-
},
|
|
10233
|
-
}, { allowProjection: true });
|
|
10234
|
-
}
|
|
10235
10426
|
function readNodeOptions(element, transition) {
|
|
10236
10427
|
const layoutAttr = element.getAttribute("data-layout");
|
|
10237
10428
|
const layoutId = element.getAttribute("data-layout-id") ?? undefined;
|
|
@@ -10247,27 +10438,7 @@
|
|
|
10247
10438
|
function prepareNode(element, transition) {
|
|
10248
10439
|
let node = layoutNodes.get(element);
|
|
10249
10440
|
if (!node) {
|
|
10250
|
-
|
|
10251
|
-
if (!visualElement) {
|
|
10252
|
-
visualElement = createVisualElement();
|
|
10253
|
-
/**
|
|
10254
|
-
* Values animate() has been rendering on this element move to
|
|
10255
|
-
* the VisualElement, so the layout animation composes with
|
|
10256
|
-
* them instead of overwriting them.
|
|
10257
|
-
*/
|
|
10258
|
-
handOffElementState(element, visualElement);
|
|
10259
|
-
}
|
|
10260
|
-
/**
|
|
10261
|
-
* A first-time element may carry a projection transform in its
|
|
10262
|
-
* inline style (e.g. it was cloned from an element mid-animation).
|
|
10263
|
-
* That transform isn't tracked in latestValues so the engine can't
|
|
10264
|
-
* reset it before measuring - clear it now so the first layout
|
|
10265
|
-
* measurement isn't inflated.
|
|
10266
|
-
*/
|
|
10267
|
-
if (element.style.transform &&
|
|
10268
|
-
!hasTransform(visualElement.latestValues)) {
|
|
10269
|
-
element.style.transform = "";
|
|
10270
|
-
}
|
|
10441
|
+
const visualElement = resolveVisualElement(element);
|
|
10271
10442
|
node = new HTMLProjectionNode(visualElement.latestValues, getProjectionParent(element));
|
|
10272
10443
|
visualElement.projection = node;
|
|
10273
10444
|
node.setOptions({
|
|
@@ -10287,10 +10458,26 @@
|
|
|
10287
10458
|
return node;
|
|
10288
10459
|
}
|
|
10289
10460
|
/**
|
|
10290
|
-
*
|
|
10291
|
-
*
|
|
10292
|
-
|
|
10293
|
-
|
|
10461
|
+
* Create a node for an element in the shared imperative tree. Returns the
|
|
10462
|
+
* node and a function that releases it.
|
|
10463
|
+
*/
|
|
10464
|
+
function createLayoutNode(element) {
|
|
10465
|
+
const node = prepareNode(element);
|
|
10466
|
+
return [
|
|
10467
|
+
node,
|
|
10468
|
+
() => layoutNodes.get(element) === node && dropNode(element, node),
|
|
10469
|
+
];
|
|
10470
|
+
}
|
|
10471
|
+
/**
|
|
10472
|
+
* Let drag() create its nodes in the shared imperative tree, so drag
|
|
10473
|
+
* gestures and layout animations work together.
|
|
10474
|
+
*/
|
|
10475
|
+
layoutProjection.create = createLayoutNode;
|
|
10476
|
+
/**
|
|
10477
|
+
* Get a projection node for an element, so motion/remix can measure and
|
|
10478
|
+
* animate its layout. Reuses a node owned by a `motion` component or
|
|
10479
|
+
* animateLayout(), otherwise creates one in the shared imperative tree.
|
|
10480
|
+
* Returns the node and a function that releases it.
|
|
10294
10481
|
*/
|
|
10295
10482
|
function acquireProjectionNode(element) {
|
|
10296
10483
|
const owned = layoutNodes.get(element) || visualElementStore.get(element)?.projection;
|
|
@@ -10298,13 +10485,7 @@
|
|
|
10298
10485
|
* A VisualElement can outlive a node we released (e.g. a stopped
|
|
10299
10486
|
* drag()), so only reuse a node that's still mounted.
|
|
10300
10487
|
*/
|
|
10301
|
-
|
|
10302
|
-
return [owned, () => { }];
|
|
10303
|
-
const node = prepareNode(element);
|
|
10304
|
-
return [
|
|
10305
|
-
node,
|
|
10306
|
-
() => layoutNodes.get(element) === node && dropNode(element, node),
|
|
10307
|
-
];
|
|
10488
|
+
return owned?.instance ? [owned, () => { }] : createLayoutNode(element);
|
|
10308
10489
|
}
|
|
10309
10490
|
function sortDocumentOrder(elements) {
|
|
10310
10491
|
return [...elements].sort((a, b) => a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1);
|
|
@@ -10324,6 +10505,8 @@
|
|
|
10324
10505
|
}
|
|
10325
10506
|
function flushPendingBuilders() {
|
|
10326
10507
|
const builders = pendingBuilders;
|
|
10508
|
+
if (!builders)
|
|
10509
|
+
return;
|
|
10327
10510
|
pendingBuilders = undefined;
|
|
10328
10511
|
flushPendingFrame();
|
|
10329
10512
|
/**
|
|
@@ -10388,6 +10571,13 @@
|
|
|
10388
10571
|
};
|
|
10389
10572
|
updatePromises.length ? Promise.all(updatePromises).then(commit) : commit();
|
|
10390
10573
|
}
|
|
10574
|
+
/**
|
|
10575
|
+
* Snapshot every pending animateLayout() now, rather than on the next
|
|
10576
|
+
* microtask. For renderers that tell us a DOM update is about to happen
|
|
10577
|
+
* and then make it synchronously (e.g. a beforeUpdate/commit pair), with
|
|
10578
|
+
* updateDom returning a promise that resolves on commit.
|
|
10579
|
+
*/
|
|
10580
|
+
const flushLayoutSnapshots = flushPendingBuilders;
|
|
10391
10581
|
class LayoutAnimationBuilder {
|
|
10392
10582
|
constructor(scope, updateDom, defaultOptions) {
|
|
10393
10583
|
this.scope = scope;
|
|
@@ -11785,13 +11975,13 @@
|
|
|
11785
11975
|
}
|
|
11786
11976
|
const cleanups = resolveElements(elementOrSelector).map((element) => {
|
|
11787
11977
|
scope?.track(element);
|
|
11788
|
-
const [node, release] =
|
|
11978
|
+
const [node, release] = acquireDragNode(element);
|
|
11789
11979
|
/**
|
|
11790
11980
|
* Measure layout even when not animating it, as constraints and
|
|
11791
11981
|
* layout-shift correction are computed from it.
|
|
11792
11982
|
*/
|
|
11793
11983
|
node.setOptions({ alwaysMeasureLayout: true });
|
|
11794
|
-
const controls = new VisualElementDragControls(
|
|
11984
|
+
const controls = new VisualElementDragControls(visualElementStore.get(element), () => props);
|
|
11795
11985
|
const removeListeners = controls.addListeners();
|
|
11796
11986
|
const removeStyles = applyDragStyles(element, options.axis);
|
|
11797
11987
|
return () => {
|
|
@@ -12197,9 +12387,19 @@
|
|
|
12197
12387
|
return scope;
|
|
12198
12388
|
}
|
|
12199
12389
|
|
|
12390
|
+
/**
|
|
12391
|
+
* The metrics projection counts, in the order of the index it passes to
|
|
12392
|
+
* statsBuffer.countProjection.
|
|
12393
|
+
*/
|
|
12394
|
+
const projectionMetrics = [
|
|
12395
|
+
"nodes",
|
|
12396
|
+
"calculatedTargetDeltas",
|
|
12397
|
+
"calculatedProjections",
|
|
12398
|
+
];
|
|
12200
12399
|
function clearStatsBuffer() {
|
|
12201
12400
|
statsBuffer.value = null;
|
|
12202
12401
|
statsBuffer.addProjectionMetrics = null;
|
|
12402
|
+
statsBuffer.countProjection = undefined;
|
|
12203
12403
|
}
|
|
12204
12404
|
function recordStats() {
|
|
12205
12405
|
if (statsBuffer.value) {
|
|
@@ -12220,6 +12420,27 @@
|
|
|
12220
12420
|
layoutProjection.calculatedTargetDeltas.push(metrics.calculatedTargetDeltas);
|
|
12221
12421
|
layoutProjection.calculatedProjections.push(metrics.calculatedProjections);
|
|
12222
12422
|
};
|
|
12423
|
+
/**
|
|
12424
|
+
* Counting lives here rather than in projection, so bundles that never
|
|
12425
|
+
* call recordStats() don't ship it.
|
|
12426
|
+
*/
|
|
12427
|
+
const metrics = {
|
|
12428
|
+
nodes: 0,
|
|
12429
|
+
calculatedTargetDeltas: 0,
|
|
12430
|
+
calculatedProjections: 0,
|
|
12431
|
+
};
|
|
12432
|
+
buffer.countProjection = (metric) => {
|
|
12433
|
+
if (metric !== undefined) {
|
|
12434
|
+
metrics[projectionMetrics[metric]]++;
|
|
12435
|
+
}
|
|
12436
|
+
else {
|
|
12437
|
+
buffer.addProjectionMetrics(metrics);
|
|
12438
|
+
metrics.nodes =
|
|
12439
|
+
metrics.calculatedTargetDeltas =
|
|
12440
|
+
metrics.calculatedProjections =
|
|
12441
|
+
0;
|
|
12442
|
+
}
|
|
12443
|
+
};
|
|
12223
12444
|
}
|
|
12224
12445
|
|
|
12225
12446
|
function getOriginIndex(from, total) {
|
|
@@ -14578,6 +14799,11 @@
|
|
|
14578
14799
|
const valueKeyframesAsList = keyframesAsList(valueKeyframes);
|
|
14579
14800
|
const { delay = 0, times = defaultOffset$1(valueKeyframesAsList), type = defaultTransition.type || "keyframes", repeat, repeatType, repeatDelay = 0, ...remainingTransition } = valueTransition;
|
|
14580
14801
|
let { ease = defaultTransition.ease || "easeOut", duration } = valueTransition;
|
|
14802
|
+
/**
|
|
14803
|
+
* The value animates as one, so it takes the first mixer
|
|
14804
|
+
* given for it, or else the default transition's.
|
|
14805
|
+
*/
|
|
14806
|
+
valueSequence.mixer || (valueSequence.mixer = valueTransition.mixer);
|
|
14581
14807
|
/**
|
|
14582
14808
|
* Resolve stagger() if defined.
|
|
14583
14809
|
*/
|
|
@@ -14811,6 +15037,7 @@
|
|
|
14811
15037
|
duration: totalDuration,
|
|
14812
15038
|
ease: valueEasing,
|
|
14813
15039
|
times: valueOffset,
|
|
15040
|
+
mixer: valueSequence.mixer || defaultTransition.mixer,
|
|
14814
15041
|
...sequenceTransition,
|
|
14815
15042
|
};
|
|
14816
15043
|
}
|
|
@@ -14977,6 +15204,16 @@
|
|
|
14977
15204
|
this.isDone = false;
|
|
14978
15205
|
this.isRebuilding = false;
|
|
14979
15206
|
this.playbackSpeed = 1;
|
|
15207
|
+
/**
|
|
15208
|
+
* The scopeMotion() scope this was created in. Rebuilds run in it, so
|
|
15209
|
+
* selectors resolve in its root and cancel() restores what they
|
|
15210
|
+
* animate.
|
|
15211
|
+
*/
|
|
15212
|
+
this.motionScope = activeScope.current;
|
|
15213
|
+
/**
|
|
15214
|
+
* Set when the scope stops, so later changes don't restart it.
|
|
15215
|
+
*/
|
|
15216
|
+
this.isKilled = false;
|
|
14980
15217
|
/**
|
|
14981
15218
|
* True while this plays the animations it was created with, before
|
|
14982
15219
|
* any change compiles it as a sequence.
|
|
@@ -15206,7 +15443,7 @@
|
|
|
15206
15443
|
* reflect it.
|
|
15207
15444
|
*/
|
|
15208
15445
|
flush() {
|
|
15209
|
-
this.isDirty && !this.parent && this.build();
|
|
15446
|
+
this.isDirty && !this.parent && !this.isKilled && this.build();
|
|
15210
15447
|
}
|
|
15211
15448
|
adopt(parent) {
|
|
15212
15449
|
if (this.group) {
|
|
@@ -15252,7 +15489,15 @@
|
|
|
15252
15489
|
Object.assign(playback, options);
|
|
15253
15490
|
const markers = new Map();
|
|
15254
15491
|
const info = {};
|
|
15255
|
-
const
|
|
15492
|
+
const prevScope = activeScope.current;
|
|
15493
|
+
activeScope.current = this.motionScope;
|
|
15494
|
+
let animations;
|
|
15495
|
+
try {
|
|
15496
|
+
animations = animateSequence(this.toSequence(markers), { defaultTransition, ...playback }, scope, info);
|
|
15497
|
+
}
|
|
15498
|
+
finally {
|
|
15499
|
+
activeScope.current = prevScope;
|
|
15500
|
+
}
|
|
15256
15501
|
const labels = info.labels;
|
|
15257
15502
|
let duration = playback.duration ?? info.duration;
|
|
15258
15503
|
/**
|
|
@@ -15424,6 +15669,15 @@
|
|
|
15424
15669
|
this.finished = new Promise((resolve) => {
|
|
15425
15670
|
this.resolveFinished = resolve;
|
|
15426
15671
|
});
|
|
15672
|
+
/**
|
|
15673
|
+
* Stay in the scope while playing, including after a change
|
|
15674
|
+
* restarts a finished timeline.
|
|
15675
|
+
*/
|
|
15676
|
+
const remove = this.motionScope?.add(() => {
|
|
15677
|
+
this.isKilled = true;
|
|
15678
|
+
this.stop();
|
|
15679
|
+
});
|
|
15680
|
+
remove && this.finished.then(remove);
|
|
15427
15681
|
}
|
|
15428
15682
|
}
|
|
15429
15683
|
|
|
@@ -15440,8 +15694,7 @@
|
|
|
15440
15694
|
* Implementation
|
|
15441
15695
|
*/
|
|
15442
15696
|
function scopedAnimate(subjectOrSequence, optionsOrKeyframes, options) {
|
|
15443
|
-
const
|
|
15444
|
-
const scopeTransition = motionScope?.transition;
|
|
15697
|
+
const scopeTransition = activeScope.current?.transition;
|
|
15445
15698
|
const inherited = {};
|
|
15446
15699
|
if (reduceMotion !== undefined)
|
|
15447
15700
|
inherited.reduceMotion = reduceMotion;
|
|
@@ -15490,9 +15743,6 @@
|
|
|
15490
15743
|
: [subjectOrSequence, optionsOrKeyframes, transition]);
|
|
15491
15744
|
timeline = new Timeline([segment], { ...inherited, onComplete, scope }, animateSubject(subjectOrSequence, optionsOrKeyframes, transition, scope));
|
|
15492
15745
|
}
|
|
15493
|
-
if (motionScope) {
|
|
15494
|
-
timeline.finished.then(motionScope.add(() => timeline.stop()));
|
|
15495
|
-
}
|
|
15496
15746
|
return timeline;
|
|
15497
15747
|
}
|
|
15498
15748
|
return scopedAnimate;
|
|
@@ -16297,6 +16547,7 @@
|
|
|
16297
16547
|
exports.VisualElement = VisualElement;
|
|
16298
16548
|
exports.VisualElementDragControls = VisualElementDragControls;
|
|
16299
16549
|
exports.acceleratedValues = acceleratedValues;
|
|
16550
|
+
exports.acquireProjectionNode = acquireProjectionNode;
|
|
16300
16551
|
exports.activeScope = activeScope;
|
|
16301
16552
|
exports.addAttrValue = addAttrValue;
|
|
16302
16553
|
exports.addBuilderToScope = addBuilderToScope;
|
|
@@ -16423,6 +16674,7 @@
|
|
|
16423
16674
|
exports.findEffect = findEffect;
|
|
16424
16675
|
exports.findValueType = findValueType;
|
|
16425
16676
|
exports.flushKeyframeResolvers = flushKeyframeResolvers;
|
|
16677
|
+
exports.flushLayoutSnapshots = flushLayoutSnapshots;
|
|
16426
16678
|
exports.followValue = followValue;
|
|
16427
16679
|
exports.frame = frame;
|
|
16428
16680
|
exports.frameData = frameData;
|