motion-dom 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/index.js +370 -147
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/JSAnimation.mjs +7 -1
- package/dist/es/animation/JSAnimation.mjs.map +1 -1
- package/dist/es/animation/generators/keyframes.mjs +12 -3
- package/dist/es/animation/generators/keyframes.mjs.map +1 -1
- package/dist/es/animation/utils/is-transition-defined.mjs +1 -0
- package/dist/es/animation/utils/is-transition-defined.mjs.map +1 -1
- package/dist/es/animation/waapi/supports/waapi.mjs +3 -1
- package/dist/es/animation/waapi/supports/waapi.mjs.map +1 -1
- package/dist/es/animation/waapi/transforms/TransformAnimation.mjs +31 -35
- package/dist/es/animation/waapi/transforms/TransformAnimation.mjs.map +1 -1
- package/dist/es/animation/waapi/utils/needs-mixer.mjs +11 -0
- package/dist/es/animation/waapi/utils/needs-mixer.mjs.map +1 -0
- package/dist/es/effects/svg/index.mjs +14 -0
- package/dist/es/effects/svg/index.mjs.map +1 -1
- package/dist/es/gestures/drag/index.mjs +4 -3
- package/dist/es/gestures/drag/index.mjs.map +1 -1
- package/dist/es/gestures/drag/projection.mjs +85 -0
- package/dist/es/gestures/drag/projection.mjs.map +1 -0
- package/dist/es/index.mjs +1 -1
- package/dist/es/layout/LayoutAnimationBuilder.mjs +34 -51
- package/dist/es/layout/LayoutAnimationBuilder.mjs.map +1 -1
- package/dist/es/layout/visual-element.mjs +48 -0
- package/dist/es/layout/visual-element.mjs.map +1 -0
- package/dist/es/projection/geometry/round.mjs +25 -0
- package/dist/es/projection/geometry/round.mjs.map +1 -0
- package/dist/es/projection/node/DocumentProjectionNode.mjs +2 -8
- package/dist/es/projection/node/DocumentProjectionNode.mjs.map +1 -1
- package/dist/es/projection/node/create-projection-node.mjs +68 -48
- package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
- package/dist/es/projection/utils/measure.mjs +5 -1
- package/dist/es/projection/utils/measure.mjs.map +1 -1
- package/dist/es/stats/buffer.mjs +1 -0
- package/dist/es/stats/buffer.mjs.map +1 -1
- package/dist/es/stats/index.mjs +31 -0
- package/dist/es/stats/index.mjs.map +1 -1
- package/dist/es/utils/interpolate.mjs +3 -2
- package/dist/es/utils/interpolate.mjs.map +1 -1
- package/dist/es/utils/is-ref-object.mjs +8 -0
- package/dist/es/utils/is-ref-object.mjs.map +1 -0
- package/dist/es/utils/transform.mjs.map +1 -1
- package/dist/es/value/index.mjs +10 -1
- package/dist/es/value/index.mjs.map +1 -1
- package/dist/index.d.ts +298 -232
- package/dist/motion-dom.dev.js +370 -147
- package/dist/motion-dom.js +1 -1
- package/dist/size-rollup-motion-value.js +1 -1
- package/dist/size-rollup-motion-value.js.map +1 -1
- package/dist/size-rollup-style-effect.js +1 -1
- package/dist/size-rollup-style-effect.js.map +1 -1
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -1311,10 +1311,11 @@ function inertia({ keyframes, velocity = 0.0, power = 0.8, timeConstant = 325, b
|
|
|
1311
1311
|
|
|
1312
1312
|
function createMixers(output, ease, customMixer) {
|
|
1313
1313
|
const mixers = [];
|
|
1314
|
-
const mixerFactory =
|
|
1314
|
+
const mixerFactory = motionUtils.MotionGlobalConfig.mix || mix;
|
|
1315
1315
|
const numMixers = output.length - 1;
|
|
1316
1316
|
for (let i = 0; i < numMixers; i++) {
|
|
1317
|
-
let mixer =
|
|
1317
|
+
let mixer = customMixer?.(output[i], output[i + 1]) ||
|
|
1318
|
+
mixerFactory(output[i], output[i + 1]);
|
|
1318
1319
|
if (ease) {
|
|
1319
1320
|
const easingFunction = Array.isArray(ease) ? ease[i] || motionUtils.noop : ease;
|
|
1320
1321
|
mixer = motionUtils.pipe(easingFunction, mixer);
|
|
@@ -1401,7 +1402,13 @@ function convertOffsetToTimes(offset, duration) {
|
|
|
1401
1402
|
function defaultEasing(values, easing) {
|
|
1402
1403
|
return values.map(() => easing || motionUtils.easeInOut).splice(0, values.length - 1);
|
|
1403
1404
|
}
|
|
1404
|
-
function keyframes({ duration = 300, keyframes: keyframeValues, times, ease = "easeInOut", }) {
|
|
1405
|
+
function keyframes({ duration = 300, keyframes: keyframeValues, times, ease = "easeInOut", mixer: transitionMixer, }) {
|
|
1406
|
+
/**
|
|
1407
|
+
* A mixer only blends values that aren't numbers. Numbers blend as
|
|
1408
|
+
* usual, as they do in springs, and so do the progress animations
|
|
1409
|
+
* behind layout and path animations, which take the same transition.
|
|
1410
|
+
*/
|
|
1411
|
+
const customMixer = typeof keyframeValues[0] === "number" ? undefined : transitionMixer;
|
|
1405
1412
|
/**
|
|
1406
1413
|
* Easing functions can be externally defined as strings. Here we convert them
|
|
1407
1414
|
* into actual functions.
|
|
@@ -1418,9 +1425,11 @@ function keyframes({ duration = 300, keyframes: keyframeValues, times, ease = "e
|
|
|
1418
1425
|
value: keyframeValues[0],
|
|
1419
1426
|
};
|
|
1420
1427
|
/**
|
|
1421
|
-
* Fast setup path for two keyframes one easing.
|
|
1428
|
+
* Fast setup path for two keyframes one easing. interpolate() handles
|
|
1429
|
+
* a custom mixer, and falls back to the usual one where it declines.
|
|
1422
1430
|
*/
|
|
1423
|
-
if (
|
|
1431
|
+
if (!customMixer &&
|
|
1432
|
+
keyframeValues.length === 2 &&
|
|
1424
1433
|
!Array.isArray(easingFunctions) &&
|
|
1425
1434
|
(!times ||
|
|
1426
1435
|
times.length !== 2 ||
|
|
@@ -1453,6 +1462,7 @@ function keyframes({ duration = 300, keyframes: keyframeValues, times, ease = "e
|
|
|
1453
1462
|
ease: Array.isArray(easingFunctions)
|
|
1454
1463
|
? easingFunctions
|
|
1455
1464
|
: defaultEasing(keyframeValues, easingFunctions),
|
|
1465
|
+
mixer: customMixer,
|
|
1456
1466
|
});
|
|
1457
1467
|
return {
|
|
1458
1468
|
calculatedDuration: duration,
|
|
@@ -1661,9 +1671,15 @@ class JSAnimation extends WithPromise {
|
|
|
1661
1671
|
generatorFactory !== keyframes) {
|
|
1662
1672
|
motionUtils.invariant(keyframes$1.length <= 2, `Only two keyframes currently supported with spring and inertia animations. Trying to animate ${keyframes$1}`, "spring-two-frames");
|
|
1663
1673
|
}
|
|
1674
|
+
/**
|
|
1675
|
+
* This runs again when a spring is flattened to attach it to a
|
|
1676
|
+
* timeline, and the keyframes generator blends values itself.
|
|
1677
|
+
*/
|
|
1678
|
+
this.mixKeyframes = undefined;
|
|
1664
1679
|
if (generatorFactory !== keyframes &&
|
|
1665
1680
|
typeof keyframes$1[0] !== "number") {
|
|
1666
|
-
this.mixKeyframes = motionUtils.pipe(percentToProgress,
|
|
1681
|
+
this.mixKeyframes = motionUtils.pipe(percentToProgress, options.mixer?.(keyframes$1[0], keyframes$1[1]) ||
|
|
1682
|
+
mix(keyframes$1[0], keyframes$1[1]));
|
|
1667
1683
|
keyframes$1 = [0, 100];
|
|
1668
1684
|
}
|
|
1669
1685
|
const generator = generatorFactory(keyframes$1 === options.keyframes
|
|
@@ -3017,6 +3033,15 @@ function hasBrowserOnlyColors(keyframes) {
|
|
|
3017
3033
|
return false;
|
|
3018
3034
|
}
|
|
3019
3035
|
|
|
3036
|
+
/**
|
|
3037
|
+
* Whether an animation needs its mixer, which WAAPI can't call. Numbers
|
|
3038
|
+
* blend as usual, and an animation whose mixer declines every pair runs
|
|
3039
|
+
* as it would without one.
|
|
3040
|
+
*/
|
|
3041
|
+
const needsMixer = ({ mixer, keyframes }) => mixer &&
|
|
3042
|
+
typeof keyframes[0] !== "number" &&
|
|
3043
|
+
keyframes.some((keyframe, i) => i && mixer(keyframes[i - 1], keyframe));
|
|
3044
|
+
|
|
3020
3045
|
const colorProperties = new Set([
|
|
3021
3046
|
"color",
|
|
3022
3047
|
"backgroundColor",
|
|
@@ -3076,7 +3101,8 @@ function supportsBrowserAnimation(options) {
|
|
|
3076
3101
|
!repeatDelay &&
|
|
3077
3102
|
repeatType !== "mirror" &&
|
|
3078
3103
|
damping !== 0 &&
|
|
3079
|
-
type !== "inertia"
|
|
3104
|
+
type !== "inertia" &&
|
|
3105
|
+
!needsMixer(options));
|
|
3080
3106
|
}
|
|
3081
3107
|
|
|
3082
3108
|
/**
|
|
@@ -3175,18 +3201,21 @@ const churnWindow = 100;
|
|
|
3175
3201
|
* Named easings that are the same cubic-bezier in JS and CSS.
|
|
3176
3202
|
*/
|
|
3177
3203
|
const isNativeEasing = (ease) => /^(linear|ease(In|Out|InOut))$/.test(ease);
|
|
3204
|
+
/**
|
|
3205
|
+
* Whether two eased progresses match. False if either is NaN.
|
|
3206
|
+
*/
|
|
3207
|
+
const isNear$1 = (a, b) => Math.abs(a - b) <= easingTolerance;
|
|
3178
3208
|
const byTime = (a, b) => a - b;
|
|
3179
3209
|
/**
|
|
3180
3210
|
* n + 1 evenly spaced timestamps, from one timestamp to another.
|
|
3181
3211
|
*/
|
|
3182
|
-
const spread = (from, to, n) =>
|
|
3183
|
-
const result = [];
|
|
3184
|
-
for (let i = 0; i <= n; i++)
|
|
3185
|
-
result.push(mixNumber$1(from, to, i / n));
|
|
3186
|
-
return result;
|
|
3187
|
-
};
|
|
3212
|
+
const spread = (from, to, n) => defaultOffset(Array(n + 1)).map((p) => mixNumber$1(from, to, p));
|
|
3188
3213
|
const getOwner = (options) => options.motionValue.owner;
|
|
3189
3214
|
const getGroup = (element) => transformGroups.get(element);
|
|
3215
|
+
/**
|
|
3216
|
+
* Whether an animation has ended, so can leave its group.
|
|
3217
|
+
*/
|
|
3218
|
+
const hasEnded = ({ state }) => state === "idle" || state === "finished";
|
|
3190
3219
|
const read = (owner, key) => owner.latestValues ? owner.latestValues[key] : owner.getValue(key)?.get();
|
|
3191
3220
|
/**
|
|
3192
3221
|
* Whether this animation should join its element's transform group.
|
|
@@ -3225,7 +3254,12 @@ function canAccelerateTransform(options) {
|
|
|
3225
3254
|
/**
|
|
3226
3255
|
* Layout animations write transform every frame.
|
|
3227
3256
|
*/
|
|
3228
|
-
!owner.projection?.isProjecting()
|
|
3257
|
+
!owner.projection?.isProjecting() &&
|
|
3258
|
+
/**
|
|
3259
|
+
* A mixer that blends these values makes them every frame. It's
|
|
3260
|
+
* asked last, as it's user code.
|
|
3261
|
+
*/
|
|
3262
|
+
!needsMixer(options));
|
|
3229
3263
|
}
|
|
3230
3264
|
class TransformAnimation extends JSAnimation {
|
|
3231
3265
|
constructor(options) {
|
|
@@ -3582,9 +3616,8 @@ function createGroup(owner) {
|
|
|
3582
3616
|
let shared;
|
|
3583
3617
|
let progressAt;
|
|
3584
3618
|
for (const track of moving) {
|
|
3585
|
-
const
|
|
3586
|
-
const
|
|
3587
|
-
const changes = values.map((value) => value - first);
|
|
3619
|
+
const first = track.numberAt(from);
|
|
3620
|
+
const changes = at.map((t) => track.numberAt(t) - first);
|
|
3588
3621
|
const end = changes[changes.length - 1];
|
|
3589
3622
|
/**
|
|
3590
3623
|
* A value that ends only a tiny way from where it started, as
|
|
@@ -3598,25 +3631,20 @@ function createGroup(owner) {
|
|
|
3598
3631
|
: end;
|
|
3599
3632
|
const progress = changes.map((change) => range ? change / range : change);
|
|
3600
3633
|
/**
|
|
3601
|
-
*
|
|
3602
|
-
*
|
|
3603
|
-
* fits
|
|
3634
|
+
* The first value that moves sets the easing, and every other
|
|
3635
|
+
* one must follow it. A value that doesn't change, like one
|
|
3636
|
+
* still in its delay, fits any easing. One that changes but
|
|
3637
|
+
* ends where it started fits none.
|
|
3604
3638
|
*/
|
|
3605
|
-
if (!
|
|
3606
|
-
if (progress.some((p) => !(Math.abs(p) <= easingTolerance))) {
|
|
3607
|
-
return;
|
|
3608
|
-
}
|
|
3609
|
-
}
|
|
3610
|
-
else if (!shared) {
|
|
3639
|
+
if (range && !shared) {
|
|
3611
3640
|
shared = progress;
|
|
3612
3641
|
progressAt = (t) => (track.numberAt(t) - first) / range;
|
|
3613
3642
|
}
|
|
3614
|
-
else if (progress.some((p, i) => !(
|
|
3643
|
+
else if (progress.some((p, i) => !isNear$1(p, range && shared[i]))) {
|
|
3615
3644
|
return;
|
|
3616
3645
|
}
|
|
3617
3646
|
}
|
|
3618
|
-
if (!shared ||
|
|
3619
|
-
shared.every((p, i) => Math.abs(p - position(at[i])) <= easingTolerance)) {
|
|
3647
|
+
if (!shared || shared.every((p, i) => isNear$1(p, position(at[i])))) {
|
|
3620
3648
|
return "linear";
|
|
3621
3649
|
}
|
|
3622
3650
|
/**
|
|
@@ -3703,7 +3731,7 @@ function createGroup(owner) {
|
|
|
3703
3731
|
/**
|
|
3704
3732
|
* A WAAPI animation of the composed transform between two timestamps.
|
|
3705
3733
|
*/
|
|
3706
|
-
const run = (moving, from, to, options = { fill: "both" }, settled
|
|
3734
|
+
const run = (moving, from, to, nativeEasing, options = { fill: "both" }, settled) => {
|
|
3707
3735
|
const bounds = moving.flatMap((track) => track.boundaries(from, to));
|
|
3708
3736
|
const easing = nativeEasing || getEasing(moving, from, to, bounds);
|
|
3709
3737
|
const times = easing ? [from, to] : sample(moving, from, to, bounds);
|
|
@@ -3789,9 +3817,7 @@ function createGroup(owner) {
|
|
|
3789
3817
|
if (byKey.has(key))
|
|
3790
3818
|
return true;
|
|
3791
3819
|
const value = (statics[key] = read(owner, key));
|
|
3792
|
-
return
|
|
3793
|
-
parseFloat(value) !==
|
|
3794
|
-
(key.startsWith("scale") ? 1 : 0));
|
|
3820
|
+
return value !== undefined && !isDefaultTransform(key, value);
|
|
3795
3821
|
});
|
|
3796
3822
|
stop(false);
|
|
3797
3823
|
/**
|
|
@@ -3802,7 +3828,7 @@ function createGroup(owner) {
|
|
|
3802
3828
|
try {
|
|
3803
3829
|
if (tween && tween[1] > now) {
|
|
3804
3830
|
const [from, to, easing] = tween;
|
|
3805
|
-
add(run(moving, from, to,
|
|
3831
|
+
add(run(moving, from, to, easing), from - now, to - from);
|
|
3806
3832
|
}
|
|
3807
3833
|
else if (end > now) {
|
|
3808
3834
|
add(run(moving, now, end), 0, end - now);
|
|
@@ -3819,7 +3845,7 @@ function createGroup(owner) {
|
|
|
3819
3845
|
* seamlessly, and start it part way through.
|
|
3820
3846
|
*/
|
|
3821
3847
|
const from = cycleStart + Math.floor((end - cycleStart) / cycle) * cycle;
|
|
3822
|
-
add(run(looping, from, from + cycle, {
|
|
3848
|
+
add(run(looping, from, from + cycle, undefined, {
|
|
3823
3849
|
iterations: Infinity,
|
|
3824
3850
|
iterationStart: (end - from) / cycle,
|
|
3825
3851
|
/**
|
|
@@ -3958,10 +3984,7 @@ function createGroup(owner) {
|
|
|
3958
3984
|
isScheduled = false;
|
|
3959
3985
|
if (isEnded)
|
|
3960
3986
|
return;
|
|
3961
|
-
tracks.forEach((
|
|
3962
|
-
if (state === "idle" || state === "finished")
|
|
3963
|
-
tracks.delete(track);
|
|
3964
|
-
});
|
|
3987
|
+
tracks.forEach((track) => hasEnded(track) && tracks.delete(track));
|
|
3965
3988
|
if (end())
|
|
3966
3989
|
return;
|
|
3967
3990
|
for (const track of tracks) {
|
|
@@ -4021,9 +4044,7 @@ function createGroup(owner) {
|
|
|
4021
4044
|
* Only drop the stopped animation. Others can be idle because
|
|
4022
4045
|
* they're part way through play(), and are about to run.
|
|
4023
4046
|
*/
|
|
4024
|
-
|
|
4025
|
-
if (state === "idle" || state === "finished")
|
|
4026
|
-
tracks.delete(track);
|
|
4047
|
+
hasEnded(track) && tracks.delete(track);
|
|
4027
4048
|
end() || group.schedule(true);
|
|
4028
4049
|
},
|
|
4029
4050
|
/**
|
|
@@ -4580,10 +4601,19 @@ class MotionValue {
|
|
|
4580
4601
|
* effects, and resets velocity to `0`.
|
|
4581
4602
|
*/
|
|
4582
4603
|
jump(v, endAnimation = true) {
|
|
4604
|
+
if (endAnimation) {
|
|
4605
|
+
/**
|
|
4606
|
+
* Stop first, as stopping a running animation can set the
|
|
4607
|
+
* value it's showing, which would replace v. Marking the value
|
|
4608
|
+
* as updated now skips a JS animation's catch-up tick on stop,
|
|
4609
|
+
* which could otherwise complete it.
|
|
4610
|
+
*/
|
|
4611
|
+
this.updatedAt = time.now();
|
|
4612
|
+
this.stop();
|
|
4613
|
+
}
|
|
4583
4614
|
this.updateAndNotify(v);
|
|
4584
4615
|
this.prev = v;
|
|
4585
4616
|
this.prevUpdatedAt = this.prevFrameValue = undefined;
|
|
4586
|
-
endAnimation && this.stop();
|
|
4587
4617
|
this.stopPassiveEffect?.();
|
|
4588
4618
|
}
|
|
4589
4619
|
dirty() {
|
|
@@ -4802,6 +4832,7 @@ const orchestrationKeys = new Set([
|
|
|
4802
4832
|
"from",
|
|
4803
4833
|
"elapsed",
|
|
4804
4834
|
"out",
|
|
4835
|
+
"mixer",
|
|
4805
4836
|
]);
|
|
4806
4837
|
/**
|
|
4807
4838
|
* Decide whether a transition is defined on a given Transition.
|
|
@@ -6361,6 +6392,20 @@ const addSVGValue = (element, state, key, value) => {
|
|
|
6361
6392
|
else if (key.startsWith("attr")) {
|
|
6362
6393
|
return addAttrValue(element, state, key, value, convertAttrKey(key));
|
|
6363
6394
|
}
|
|
6395
|
+
else if (key === "d") {
|
|
6396
|
+
/**
|
|
6397
|
+
* `d` is a CSS property in Chrome and Firefox, but only as
|
|
6398
|
+
* `path(...)`, so path data goes to the attribute, taken out of
|
|
6399
|
+
* `path(...)` if it's written that way. Path data itself has no
|
|
6400
|
+
* quotes or brackets.
|
|
6401
|
+
*/
|
|
6402
|
+
return state.set(key, value, () => {
|
|
6403
|
+
const d = value.get()?.replace(/path\(|["')]/g, "");
|
|
6404
|
+
d === undefined
|
|
6405
|
+
? element.removeAttribute(key)
|
|
6406
|
+
: element.setAttribute(key, d);
|
|
6407
|
+
});
|
|
6408
|
+
}
|
|
6364
6409
|
/**
|
|
6365
6410
|
* Transforms and origins aren't CSS properties (bar `x`/`y` in some
|
|
6366
6411
|
* browsers), so check them by name rather than `key in element.style`.
|
|
@@ -6617,6 +6662,10 @@ function measurePageBox(element, rootProjectionNode, transformPagePoint) {
|
|
|
6617
6662
|
}
|
|
6618
6663
|
return viewportBox;
|
|
6619
6664
|
}
|
|
6665
|
+
const measureDocumentScroll = () => ({
|
|
6666
|
+
x: document.documentElement.scrollLeft || document.body?.scrollLeft || 0,
|
|
6667
|
+
y: document.documentElement.scrollTop || document.body?.scrollTop || 0,
|
|
6668
|
+
});
|
|
6620
6669
|
|
|
6621
6670
|
const noProps = {};
|
|
6622
6671
|
const getElementEffect = (element) => (isSVGElement(element)
|
|
@@ -6793,6 +6842,7 @@ function isForcedMotionValue(key, { layout, layoutId }) {
|
|
|
6793
6842
|
const statsBuffer = {
|
|
6794
6843
|
value: null,
|
|
6795
6844
|
addProjectionMetrics: null,
|
|
6845
|
+
countProjection: undefined,
|
|
6796
6846
|
};
|
|
6797
6847
|
|
|
6798
6848
|
/**
|
|
@@ -6815,6 +6865,12 @@ function delayInSeconds(callback, timeout) {
|
|
|
6815
6865
|
return delay(callback, motionUtils.secondsToMilliseconds(timeout));
|
|
6816
6866
|
}
|
|
6817
6867
|
|
|
6868
|
+
function isRefObject(ref) {
|
|
6869
|
+
return (ref &&
|
|
6870
|
+
typeof ref === "object" &&
|
|
6871
|
+
Object.prototype.hasOwnProperty.call(ref, "current"));
|
|
6872
|
+
}
|
|
6873
|
+
|
|
6818
6874
|
/**
|
|
6819
6875
|
* Checks if an element is specifically an SVGSVGElement (the root SVG element)
|
|
6820
6876
|
* in a way that works across iframes
|
|
@@ -7029,6 +7085,27 @@ function removeBoxTransforms(box, transforms, originBox, sourceBox) {
|
|
|
7029
7085
|
removeAxisTransforms(box.y, transforms, yKeys, originBox?.y, sourceBox?.y);
|
|
7030
7086
|
}
|
|
7031
7087
|
|
|
7088
|
+
const userAgentContains = (string) => typeof navigator !== "undefined" &&
|
|
7089
|
+
navigator.userAgent &&
|
|
7090
|
+
navigator.userAgent.toLowerCase().includes(string);
|
|
7091
|
+
/**
|
|
7092
|
+
* Measured bounding boxes must be rounded in Safari and
|
|
7093
|
+
* left untouched in Chrome, otherwise non-integer layouts within scaled-up elements
|
|
7094
|
+
* can appear to jump.
|
|
7095
|
+
*/
|
|
7096
|
+
const roundPoint = userAgentContains("applewebkit/") && !userAgentContains("chrome/")
|
|
7097
|
+
? Math.round
|
|
7098
|
+
: motionUtils.noop;
|
|
7099
|
+
function roundAxis(axis) {
|
|
7100
|
+
// Round to the nearest .5 pixels to support subpixel layouts
|
|
7101
|
+
axis.min = roundPoint(axis.min);
|
|
7102
|
+
axis.max = roundPoint(axis.max);
|
|
7103
|
+
}
|
|
7104
|
+
function roundBox(box) {
|
|
7105
|
+
roundAxis(box.x);
|
|
7106
|
+
roundAxis(box.y);
|
|
7107
|
+
}
|
|
7108
|
+
|
|
7032
7109
|
const createAxisDelta = () => ({
|
|
7033
7110
|
translate: 0,
|
|
7034
7111
|
scale: 1,
|
|
@@ -7325,11 +7402,6 @@ const globalProjectionState = {
|
|
|
7325
7402
|
hasEverUpdated: false,
|
|
7326
7403
|
};
|
|
7327
7404
|
|
|
7328
|
-
const metrics = {
|
|
7329
|
-
nodes: 0,
|
|
7330
|
-
calculatedTargetDeltas: 0,
|
|
7331
|
-
calculatedProjections: 0,
|
|
7332
|
-
};
|
|
7333
7405
|
/**
|
|
7334
7406
|
* Transforms that distort an element's layout, so must be reset before measuring.
|
|
7335
7407
|
*/
|
|
@@ -7377,6 +7449,13 @@ function cancelTreeOptimisedTransformAnimations(projectionNode) {
|
|
|
7377
7449
|
cancelTreeOptimisedTransformAnimations(parent);
|
|
7378
7450
|
}
|
|
7379
7451
|
}
|
|
7452
|
+
function getClosestProjectingNode(visualElement) {
|
|
7453
|
+
if (!visualElement)
|
|
7454
|
+
return undefined;
|
|
7455
|
+
return visualElement.options.allowProjection !== false
|
|
7456
|
+
? visualElement.projection
|
|
7457
|
+
: getClosestProjectingNode(visualElement.parent);
|
|
7458
|
+
}
|
|
7380
7459
|
function createProjectionNode({ attachResizeListener, defaultParent, measureScroll, checkIsScrollRoot, resetTransform, }) {
|
|
7381
7460
|
/**
|
|
7382
7461
|
* Correctors registered via addScaleCorrector before projection loaded
|
|
@@ -7389,6 +7468,57 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
7389
7468
|
...scaleCorrectors,
|
|
7390
7469
|
});
|
|
7391
7470
|
return class ProjectionNode {
|
|
7471
|
+
/**
|
|
7472
|
+
* Create the projection node of a `motion` component's VisualElement,
|
|
7473
|
+
* from its props. This runs while the component renders, before its
|
|
7474
|
+
* children. It's here rather than in the component so React
|
|
7475
|
+
* bundles only include it with the features that supply a
|
|
7476
|
+
* ProjectionNode. Vanilla bundles that use the projection node
|
|
7477
|
+
* (drag(), animateLayout()) include it too, as a class static
|
|
7478
|
+
* can't be tree-shaken.
|
|
7479
|
+
*/
|
|
7480
|
+
static create(visualElement, props, initialPromotionConfig) {
|
|
7481
|
+
const { layoutId, layout, drag, dragConstraints, layoutScroll, layoutRoot, layoutAnchor, layoutCrossfade, } = props;
|
|
7482
|
+
const projection = (visualElement.projection = new this(visualElement.latestValues, props["data-framer-portal-id"]
|
|
7483
|
+
? undefined
|
|
7484
|
+
: getClosestProjectingNode(visualElement.parent)));
|
|
7485
|
+
projection.setOptions({
|
|
7486
|
+
layoutId,
|
|
7487
|
+
layout,
|
|
7488
|
+
alwaysMeasureLayout: Boolean(drag) ||
|
|
7489
|
+
(dragConstraints && isRefObject(dragConstraints)),
|
|
7490
|
+
visualElement,
|
|
7491
|
+
/**
|
|
7492
|
+
* TODO: Update options in an effect. This could be tricky as it'll be too late
|
|
7493
|
+
* to update by the time layout animations run.
|
|
7494
|
+
* We also need to fix this safeToRemove by linking it up to the one returned by usePresence,
|
|
7495
|
+
* ensuring it gets called if there's no potential layout animations.
|
|
7496
|
+
*
|
|
7497
|
+
*/
|
|
7498
|
+
animationType: typeof layout === "string" ? layout : "both",
|
|
7499
|
+
initialPromotionConfig,
|
|
7500
|
+
crossfade: layoutCrossfade,
|
|
7501
|
+
layoutScroll,
|
|
7502
|
+
layoutRoot,
|
|
7503
|
+
layoutAnchor,
|
|
7504
|
+
});
|
|
7505
|
+
/**
|
|
7506
|
+
* This node will take over from its layoutId's current lead, so snapshot
|
|
7507
|
+
* the lead now, while rendering. By the time the lead unmounts (or this
|
|
7508
|
+
* node mounts) React may already have committed DOM changes that come
|
|
7509
|
+
* before it in the tree, like a sibling changing height, and a snapshot
|
|
7510
|
+
* taken then starts the animation from a position never seen on screen.
|
|
7511
|
+
*
|
|
7512
|
+
* If React discards this render (e.g. it suspends), nothing else
|
|
7513
|
+
* completes the update, so check it after the next frame as an
|
|
7514
|
+
* unmounting node does.
|
|
7515
|
+
*/
|
|
7516
|
+
const lead = projection.getStack()?.lead;
|
|
7517
|
+
if (lead && !projection.root.isUpdateBlocked()) {
|
|
7518
|
+
lead.willUpdate();
|
|
7519
|
+
lead.scheduleCheckAfterUnmount();
|
|
7520
|
+
}
|
|
7521
|
+
}
|
|
7392
7522
|
constructor(latestValues = {}, parent = defaultParent?.()) {
|
|
7393
7523
|
/**
|
|
7394
7524
|
* A unique ID generated for every projection node.
|
|
@@ -7501,23 +7631,14 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
7501
7631
|
*/
|
|
7502
7632
|
this.updateProjection = () => {
|
|
7503
7633
|
this.projectionUpdateScheduled = false;
|
|
7504
|
-
/**
|
|
7505
|
-
* Reset debug counts. Manually resetting rather than creating a new
|
|
7506
|
-
* object each frame.
|
|
7507
|
-
*/
|
|
7508
|
-
if (statsBuffer.value) {
|
|
7509
|
-
metrics.nodes =
|
|
7510
|
-
metrics.calculatedTargetDeltas =
|
|
7511
|
-
metrics.calculatedProjections =
|
|
7512
|
-
0;
|
|
7513
|
-
}
|
|
7514
7634
|
this.nodes.forEach(propagateDirtyNodes);
|
|
7515
7635
|
this.nodes.forEach(resolveTargetDelta);
|
|
7516
7636
|
this.nodes.forEach(calcProjection);
|
|
7517
7637
|
this.nodes.forEach(cleanDirtyNodes);
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7638
|
+
/**
|
|
7639
|
+
* Record this frame's debug counts, if recordStats() is running.
|
|
7640
|
+
*/
|
|
7641
|
+
statsBuffer.countProjection?.();
|
|
7521
7642
|
};
|
|
7522
7643
|
/**
|
|
7523
7644
|
* Frame calculations
|
|
@@ -8233,9 +8354,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
8233
8354
|
/**
|
|
8234
8355
|
* Increase debug counter for resolved target deltas
|
|
8235
8356
|
*/
|
|
8236
|
-
|
|
8237
|
-
metrics.calculatedTargetDeltas++;
|
|
8238
|
-
}
|
|
8357
|
+
statsBuffer.countProjection?.(1); // calculatedTargetDeltas
|
|
8239
8358
|
}
|
|
8240
8359
|
getClosestProjectingParent() {
|
|
8241
8360
|
if (!this.parent ||
|
|
@@ -8383,9 +8502,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
8383
8502
|
/**
|
|
8384
8503
|
* Increase debug counter for recalculated projections
|
|
8385
8504
|
*/
|
|
8386
|
-
|
|
8387
|
-
metrics.calculatedProjections++;
|
|
8388
|
-
}
|
|
8505
|
+
statsBuffer.countProjection?.(2); // calculatedProjections
|
|
8389
8506
|
}
|
|
8390
8507
|
hide() {
|
|
8391
8508
|
this.isVisible = false;
|
|
@@ -8912,9 +9029,7 @@ function propagateDirtyNodes(node) {
|
|
|
8912
9029
|
/**
|
|
8913
9030
|
* Increase debug counter for nodes encountered this frame
|
|
8914
9031
|
*/
|
|
8915
|
-
|
|
8916
|
-
metrics.nodes++;
|
|
8917
|
-
}
|
|
9032
|
+
statsBuffer.countProjection?.(0); // nodes
|
|
8918
9033
|
if (!node.parent)
|
|
8919
9034
|
return;
|
|
8920
9035
|
/**
|
|
@@ -9045,26 +9160,6 @@ const defaultLayoutTransition = {
|
|
|
9045
9160
|
duration: 0.45,
|
|
9046
9161
|
ease: [0.4, 0, 0.1, 1],
|
|
9047
9162
|
};
|
|
9048
|
-
const userAgentContains = (string) => typeof navigator !== "undefined" &&
|
|
9049
|
-
navigator.userAgent &&
|
|
9050
|
-
navigator.userAgent.toLowerCase().includes(string);
|
|
9051
|
-
/**
|
|
9052
|
-
* Measured bounding boxes must be rounded in Safari and
|
|
9053
|
-
* left untouched in Chrome, otherwise non-integer layouts within scaled-up elements
|
|
9054
|
-
* can appear to jump.
|
|
9055
|
-
*/
|
|
9056
|
-
const roundPoint = userAgentContains("applewebkit/") && !userAgentContains("chrome/")
|
|
9057
|
-
? Math.round
|
|
9058
|
-
: motionUtils.noop;
|
|
9059
|
-
function roundAxis(axis) {
|
|
9060
|
-
// Round to the nearest .5 pixels to support subpixel layouts
|
|
9061
|
-
axis.min = roundPoint(axis.min);
|
|
9062
|
-
axis.max = roundPoint(axis.max);
|
|
9063
|
-
}
|
|
9064
|
-
function roundBox(box) {
|
|
9065
|
-
roundAxis(box.x);
|
|
9066
|
-
roundAxis(box.y);
|
|
9067
|
-
}
|
|
9068
9163
|
/**
|
|
9069
9164
|
* Align an axis to the start of another, keeping the length of a layout axis.
|
|
9070
9165
|
* The length is read first, as output can be the layout axis itself.
|
|
@@ -9089,14 +9184,7 @@ function addDomEvent(target, eventName, handler, options = { passive: true }) {
|
|
|
9089
9184
|
const DocumentProjectionNode =
|
|
9090
9185
|
/* @__PURE__ */ createProjectionNode({
|
|
9091
9186
|
attachResizeListener: (ref, notify) => addDomEvent(ref, "resize", notify),
|
|
9092
|
-
measureScroll:
|
|
9093
|
-
x: document.documentElement.scrollLeft ||
|
|
9094
|
-
document.body?.scrollLeft ||
|
|
9095
|
-
0,
|
|
9096
|
-
y: document.documentElement.scrollTop ||
|
|
9097
|
-
document.body?.scrollTop ||
|
|
9098
|
-
0,
|
|
9099
|
-
}),
|
|
9187
|
+
measureScroll: measureDocumentScroll,
|
|
9100
9188
|
checkIsScrollRoot: () => true,
|
|
9101
9189
|
});
|
|
9102
9190
|
|
|
@@ -9863,6 +9951,124 @@ class HTMLVisualElement extends DOMVisualElement {
|
|
|
9863
9951
|
}
|
|
9864
9952
|
}
|
|
9865
9953
|
|
|
9954
|
+
/**
|
|
9955
|
+
* Get the VisualElement that imperative APIs like animateLayout() and
|
|
9956
|
+
* drag() render an element with, creating one if it has none, ready for
|
|
9957
|
+
* a projection node to be attached.
|
|
9958
|
+
*/
|
|
9959
|
+
function resolveVisualElement(element) {
|
|
9960
|
+
let visualElement = visualElementStore.get(element);
|
|
9961
|
+
if (!visualElement) {
|
|
9962
|
+
visualElement = new HTMLVisualElement({
|
|
9963
|
+
props: {},
|
|
9964
|
+
presenceContext: null,
|
|
9965
|
+
visualState: {
|
|
9966
|
+
latestValues: {},
|
|
9967
|
+
renderState: {
|
|
9968
|
+
transform: {},
|
|
9969
|
+
transformOrigin: {},
|
|
9970
|
+
style: {},
|
|
9971
|
+
vars: {},
|
|
9972
|
+
},
|
|
9973
|
+
},
|
|
9974
|
+
}, { allowProjection: true });
|
|
9975
|
+
/**
|
|
9976
|
+
* Values animate() has been rendering on this element move to
|
|
9977
|
+
* the VisualElement, so the layout animation composes with
|
|
9978
|
+
* them instead of overwriting them.
|
|
9979
|
+
*/
|
|
9980
|
+
handOffElementState(element, visualElement);
|
|
9981
|
+
}
|
|
9982
|
+
/**
|
|
9983
|
+
* A first-time element may carry a projection transform in its
|
|
9984
|
+
* inline style (e.g. it was cloned from an element mid-animation).
|
|
9985
|
+
* That transform isn't tracked in latestValues so the engine can't
|
|
9986
|
+
* reset it before measuring - clear it now so the first layout
|
|
9987
|
+
* measurement isn't inflated.
|
|
9988
|
+
*/
|
|
9989
|
+
if (element.style.transform && !hasTransform(visualElement.latestValues)) {
|
|
9990
|
+
element.style.transform = "";
|
|
9991
|
+
}
|
|
9992
|
+
return visualElement;
|
|
9993
|
+
}
|
|
9994
|
+
|
|
9995
|
+
/**
|
|
9996
|
+
* animateLayout() registers a function here that creates nodes in the
|
|
9997
|
+
* layout projection tree. When it's in the bundle, drag() uses those, so
|
|
9998
|
+
* the two work together (e.g. a drag follows a layout change mid-gesture).
|
|
9999
|
+
* Otherwise drag() makes do with a node that only measures. Bundles that
|
|
10000
|
+
* don't tree-shake (dev pre-bundling, CDN builds) always register it, and
|
|
10001
|
+
* a drag() started before animateLayout() is lazy loaded keeps its node.
|
|
10002
|
+
*/
|
|
10003
|
+
const layoutProjection = {};
|
|
10004
|
+
/**
|
|
10005
|
+
* The document root of measurement-only nodes. Like the projection tree's
|
|
10006
|
+
* root, it keeps its scroll until drag controls clear it to re-measure.
|
|
10007
|
+
*/
|
|
10008
|
+
const root = {
|
|
10009
|
+
updateScroll: () => {
|
|
10010
|
+
root.scroll || (root.scroll = { offset: measureDocumentScroll() });
|
|
10011
|
+
},
|
|
10012
|
+
};
|
|
10013
|
+
/**
|
|
10014
|
+
* The part of a projection node that drag controls use: measuring the
|
|
10015
|
+
* element's page box, for its layout and constraints. It never projects
|
|
10016
|
+
* or joins a layout update.
|
|
10017
|
+
*/
|
|
10018
|
+
const createMeasureNode = (element) => {
|
|
10019
|
+
const visualElement = resolveVisualElement(element);
|
|
10020
|
+
const measureListeners = new motionUtils.SubscriptionManager();
|
|
10021
|
+
const node = {
|
|
10022
|
+
instance: element,
|
|
10023
|
+
root,
|
|
10024
|
+
path: [root],
|
|
10025
|
+
setOptions: motionUtils.noop,
|
|
10026
|
+
/**
|
|
10027
|
+
* Truthy like the full node's method, which HTMLVisualElement reads
|
|
10028
|
+
* (rather than calls) to default transform values.
|
|
10029
|
+
*/
|
|
10030
|
+
isProjecting: motionUtils.noop,
|
|
10031
|
+
applyProjectionStyles: motionUtils.noop,
|
|
10032
|
+
removeElementScroll: (box) => box,
|
|
10033
|
+
updateLayout: () => {
|
|
10034
|
+
const layoutBox = measurePageBox(element, root, visualElement.getTransformPagePoint());
|
|
10035
|
+
roundBox(layoutBox);
|
|
10036
|
+
node.layout = { layoutBox };
|
|
10037
|
+
measureListeners.notify();
|
|
10038
|
+
},
|
|
10039
|
+
addEventListener: (name, handler) => name === "measure" ? measureListeners.add(handler) : motionUtils.noop,
|
|
10040
|
+
/**
|
|
10041
|
+
* Detach from the VisualElement too, so it doesn't later remount
|
|
10042
|
+
* (or a `motion` component's layout feature adopt) a node that
|
|
10043
|
+
* can't do either.
|
|
10044
|
+
*/
|
|
10045
|
+
unmount: () => {
|
|
10046
|
+
node.instance = undefined;
|
|
10047
|
+
if (visualElement.projection === node) {
|
|
10048
|
+
visualElement.projection = undefined;
|
|
10049
|
+
}
|
|
10050
|
+
},
|
|
10051
|
+
};
|
|
10052
|
+
visualElement.projection = node;
|
|
10053
|
+
visualElement.current || visualElement.mount(element);
|
|
10054
|
+
return [node, node.unmount];
|
|
10055
|
+
};
|
|
10056
|
+
/**
|
|
10057
|
+
* Get a projection node for drag() to measure an element with, and a
|
|
10058
|
+
* function that releases it. Reuses a node a `motion` component or
|
|
10059
|
+
* animateLayout() owns.
|
|
10060
|
+
*/
|
|
10061
|
+
const acquireDragNode = (element) => {
|
|
10062
|
+
const owned = visualElementStore.get(element)?.projection;
|
|
10063
|
+
/**
|
|
10064
|
+
* A VisualElement can outlive its node (e.g. an unmounted `motion`
|
|
10065
|
+
* component's), so only reuse a node that's still mounted.
|
|
10066
|
+
*/
|
|
10067
|
+
return owned?.instance
|
|
10068
|
+
? [owned, motionUtils.noop]
|
|
10069
|
+
: (layoutProjection.create || createMeasureNode)(element);
|
|
10070
|
+
};
|
|
10071
|
+
|
|
9866
10072
|
const layoutSelector = "[data-layout],[data-layout-id]";
|
|
9867
10073
|
/**
|
|
9868
10074
|
* All imperatively-created projection nodes live in one persistent tree,
|
|
@@ -9915,21 +10121,6 @@ function getProjectionParent(element) {
|
|
|
9915
10121
|
}
|
|
9916
10122
|
return undefined;
|
|
9917
10123
|
}
|
|
9918
|
-
function createVisualElement() {
|
|
9919
|
-
return new HTMLVisualElement({
|
|
9920
|
-
props: {},
|
|
9921
|
-
presenceContext: null,
|
|
9922
|
-
visualState: {
|
|
9923
|
-
latestValues: {},
|
|
9924
|
-
renderState: {
|
|
9925
|
-
transform: {},
|
|
9926
|
-
transformOrigin: {},
|
|
9927
|
-
style: {},
|
|
9928
|
-
vars: {},
|
|
9929
|
-
},
|
|
9930
|
-
},
|
|
9931
|
-
}, { allowProjection: true });
|
|
9932
|
-
}
|
|
9933
10124
|
function readNodeOptions(element, transition) {
|
|
9934
10125
|
const layoutAttr = element.getAttribute("data-layout");
|
|
9935
10126
|
const layoutId = element.getAttribute("data-layout-id") ?? undefined;
|
|
@@ -9945,27 +10136,7 @@ function readNodeOptions(element, transition) {
|
|
|
9945
10136
|
function prepareNode(element, transition) {
|
|
9946
10137
|
let node = layoutNodes.get(element);
|
|
9947
10138
|
if (!node) {
|
|
9948
|
-
|
|
9949
|
-
if (!visualElement) {
|
|
9950
|
-
visualElement = createVisualElement();
|
|
9951
|
-
/**
|
|
9952
|
-
* Values animate() has been rendering on this element move to
|
|
9953
|
-
* the VisualElement, so the layout animation composes with
|
|
9954
|
-
* them instead of overwriting them.
|
|
9955
|
-
*/
|
|
9956
|
-
handOffElementState(element, visualElement);
|
|
9957
|
-
}
|
|
9958
|
-
/**
|
|
9959
|
-
* A first-time element may carry a projection transform in its
|
|
9960
|
-
* inline style (e.g. it was cloned from an element mid-animation).
|
|
9961
|
-
* That transform isn't tracked in latestValues so the engine can't
|
|
9962
|
-
* reset it before measuring - clear it now so the first layout
|
|
9963
|
-
* measurement isn't inflated.
|
|
9964
|
-
*/
|
|
9965
|
-
if (element.style.transform &&
|
|
9966
|
-
!hasTransform(visualElement.latestValues)) {
|
|
9967
|
-
element.style.transform = "";
|
|
9968
|
-
}
|
|
10139
|
+
const visualElement = resolveVisualElement(element);
|
|
9969
10140
|
node = new HTMLProjectionNode(visualElement.latestValues, getProjectionParent(element));
|
|
9970
10141
|
visualElement.projection = node;
|
|
9971
10142
|
node.setOptions({
|
|
@@ -9985,10 +10156,26 @@ function prepareNode(element, transition) {
|
|
|
9985
10156
|
return node;
|
|
9986
10157
|
}
|
|
9987
10158
|
/**
|
|
9988
|
-
*
|
|
9989
|
-
*
|
|
9990
|
-
|
|
9991
|
-
|
|
10159
|
+
* Create a node for an element in the shared imperative tree. Returns the
|
|
10160
|
+
* node and a function that releases it.
|
|
10161
|
+
*/
|
|
10162
|
+
function createLayoutNode(element) {
|
|
10163
|
+
const node = prepareNode(element);
|
|
10164
|
+
return [
|
|
10165
|
+
node,
|
|
10166
|
+
() => layoutNodes.get(element) === node && dropNode(element, node),
|
|
10167
|
+
];
|
|
10168
|
+
}
|
|
10169
|
+
/**
|
|
10170
|
+
* Let drag() create its nodes in the shared imperative tree, so drag
|
|
10171
|
+
* gestures and layout animations work together.
|
|
10172
|
+
*/
|
|
10173
|
+
layoutProjection.create = createLayoutNode;
|
|
10174
|
+
/**
|
|
10175
|
+
* Get a projection node for an element, so motion/remix can measure and
|
|
10176
|
+
* animate its layout. Reuses a node owned by a `motion` component or
|
|
10177
|
+
* animateLayout(), otherwise creates one in the shared imperative tree.
|
|
10178
|
+
* Returns the node and a function that releases it.
|
|
9992
10179
|
*/
|
|
9993
10180
|
function acquireProjectionNode(element) {
|
|
9994
10181
|
const owned = layoutNodes.get(element) || visualElementStore.get(element)?.projection;
|
|
@@ -9996,13 +10183,7 @@ function acquireProjectionNode(element) {
|
|
|
9996
10183
|
* A VisualElement can outlive a node we released (e.g. a stopped
|
|
9997
10184
|
* drag()), so only reuse a node that's still mounted.
|
|
9998
10185
|
*/
|
|
9999
|
-
|
|
10000
|
-
return [owned, () => { }];
|
|
10001
|
-
const node = prepareNode(element);
|
|
10002
|
-
return [
|
|
10003
|
-
node,
|
|
10004
|
-
() => layoutNodes.get(element) === node && dropNode(element, node),
|
|
10005
|
-
];
|
|
10186
|
+
return owned?.instance ? [owned, () => { }] : createLayoutNode(element);
|
|
10006
10187
|
}
|
|
10007
10188
|
function sortDocumentOrder(elements) {
|
|
10008
10189
|
return [...elements].sort((a, b) => a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1);
|
|
@@ -10022,6 +10203,8 @@ function dropNode(element, node) {
|
|
|
10022
10203
|
}
|
|
10023
10204
|
function flushPendingBuilders() {
|
|
10024
10205
|
const builders = pendingBuilders;
|
|
10206
|
+
if (!builders)
|
|
10207
|
+
return;
|
|
10025
10208
|
pendingBuilders = undefined;
|
|
10026
10209
|
flushPendingFrame();
|
|
10027
10210
|
/**
|
|
@@ -10086,6 +10269,13 @@ function flushPendingBuilders() {
|
|
|
10086
10269
|
};
|
|
10087
10270
|
updatePromises.length ? Promise.all(updatePromises).then(commit) : commit();
|
|
10088
10271
|
}
|
|
10272
|
+
/**
|
|
10273
|
+
* Snapshot every pending animateLayout() now, rather than on the next
|
|
10274
|
+
* microtask. For renderers that tell us a DOM update is about to happen
|
|
10275
|
+
* and then make it synchronously (e.g. a beforeUpdate/commit pair), with
|
|
10276
|
+
* updateDom returning a promise that resolves on commit.
|
|
10277
|
+
*/
|
|
10278
|
+
const flushLayoutSnapshots = flushPendingBuilders;
|
|
10089
10279
|
class LayoutAnimationBuilder {
|
|
10090
10280
|
constructor(scope, updateDom, defaultOptions) {
|
|
10091
10281
|
this.scope = scope;
|
|
@@ -11484,13 +11674,13 @@ function drag(elementOrSelector, options = {}) {
|
|
|
11484
11674
|
}
|
|
11485
11675
|
const cleanups = resolveElements(elementOrSelector).map((element) => {
|
|
11486
11676
|
scope?.track(element);
|
|
11487
|
-
const [node, release] =
|
|
11677
|
+
const [node, release] = acquireDragNode(element);
|
|
11488
11678
|
/**
|
|
11489
11679
|
* Measure layout even when not animating it, as constraints and
|
|
11490
11680
|
* layout-shift correction are computed from it.
|
|
11491
11681
|
*/
|
|
11492
11682
|
node.setOptions({ alwaysMeasureLayout: true });
|
|
11493
|
-
const controls = new VisualElementDragControls(
|
|
11683
|
+
const controls = new VisualElementDragControls(visualElementStore.get(element), () => props);
|
|
11494
11684
|
const removeListeners = controls.addListeners();
|
|
11495
11685
|
const removeStyles = applyDragStyles(element, options.axis);
|
|
11496
11686
|
return () => {
|
|
@@ -11896,9 +12086,19 @@ function scopeMotion(...args) {
|
|
|
11896
12086
|
return scope;
|
|
11897
12087
|
}
|
|
11898
12088
|
|
|
12089
|
+
/**
|
|
12090
|
+
* The metrics projection counts, in the order of the index it passes to
|
|
12091
|
+
* statsBuffer.countProjection.
|
|
12092
|
+
*/
|
|
12093
|
+
const projectionMetrics = [
|
|
12094
|
+
"nodes",
|
|
12095
|
+
"calculatedTargetDeltas",
|
|
12096
|
+
"calculatedProjections",
|
|
12097
|
+
];
|
|
11899
12098
|
function clearStatsBuffer() {
|
|
11900
12099
|
statsBuffer.value = null;
|
|
11901
12100
|
statsBuffer.addProjectionMetrics = null;
|
|
12101
|
+
statsBuffer.countProjection = undefined;
|
|
11902
12102
|
}
|
|
11903
12103
|
function recordStats() {
|
|
11904
12104
|
if (statsBuffer.value) {
|
|
@@ -11919,6 +12119,27 @@ function recordStats() {
|
|
|
11919
12119
|
layoutProjection.calculatedTargetDeltas.push(metrics.calculatedTargetDeltas);
|
|
11920
12120
|
layoutProjection.calculatedProjections.push(metrics.calculatedProjections);
|
|
11921
12121
|
};
|
|
12122
|
+
/**
|
|
12123
|
+
* Counting lives here rather than in projection, so bundles that never
|
|
12124
|
+
* call recordStats() don't ship it.
|
|
12125
|
+
*/
|
|
12126
|
+
const metrics = {
|
|
12127
|
+
nodes: 0,
|
|
12128
|
+
calculatedTargetDeltas: 0,
|
|
12129
|
+
calculatedProjections: 0,
|
|
12130
|
+
};
|
|
12131
|
+
buffer.countProjection = (metric) => {
|
|
12132
|
+
if (metric !== undefined) {
|
|
12133
|
+
metrics[projectionMetrics[metric]]++;
|
|
12134
|
+
}
|
|
12135
|
+
else {
|
|
12136
|
+
buffer.addProjectionMetrics(metrics);
|
|
12137
|
+
metrics.nodes =
|
|
12138
|
+
metrics.calculatedTargetDeltas =
|
|
12139
|
+
metrics.calculatedProjections =
|
|
12140
|
+
0;
|
|
12141
|
+
}
|
|
12142
|
+
};
|
|
11922
12143
|
}
|
|
11923
12144
|
|
|
11924
12145
|
function getOriginIndex(from, total) {
|
|
@@ -14117,6 +14338,7 @@ exports.ViewTransitionBuilder = ViewTransitionBuilder;
|
|
|
14117
14338
|
exports.VisualElement = VisualElement;
|
|
14118
14339
|
exports.VisualElementDragControls = VisualElementDragControls;
|
|
14119
14340
|
exports.acceleratedValues = acceleratedValues;
|
|
14341
|
+
exports.acquireProjectionNode = acquireProjectionNode;
|
|
14120
14342
|
exports.activeScope = activeScope;
|
|
14121
14343
|
exports.addAttrValue = addAttrValue;
|
|
14122
14344
|
exports.addBuilderToScope = addBuilderToScope;
|
|
@@ -14226,6 +14448,7 @@ exports.findDimensionValueType = findDimensionValueType;
|
|
|
14226
14448
|
exports.findEffect = findEffect;
|
|
14227
14449
|
exports.findValueType = findValueType;
|
|
14228
14450
|
exports.flushKeyframeResolvers = flushKeyframeResolvers;
|
|
14451
|
+
exports.flushLayoutSnapshots = flushLayoutSnapshots;
|
|
14229
14452
|
exports.followValue = followValue;
|
|
14230
14453
|
exports.frame = frame;
|
|
14231
14454
|
exports.frameData = frameData;
|