motion-dom 14.2.0 → 14.3.1
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 +257 -106
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/animate/effects.mjs +9 -1
- package/dist/es/animation/animate/effects.mjs.map +1 -1
- package/dist/es/animation/interfaces/visual-element-target.mjs +3 -1
- package/dist/es/animation/interfaces/visual-element-target.mjs.map +1 -1
- package/dist/es/animation/utils/arc.mjs +4 -4
- package/dist/es/animation/utils/arc.mjs.map +1 -1
- package/dist/es/animation/waapi/transforms/TransformAnimation.mjs +56 -8
- package/dist/es/animation/waapi/transforms/TransformAnimation.mjs.map +1 -1
- package/dist/es/effects/svg/index.mjs +1 -1
- package/dist/es/effects/svg/index.mjs.map +1 -1
- package/dist/es/projection/animation/mix-values.mjs +16 -3
- package/dist/es/projection/animation/mix-values.mjs.map +1 -1
- package/dist/es/projection/node/create-projection-node.mjs +91 -73
- package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
- package/dist/es/projection/styles/transform.mjs +3 -1
- package/dist/es/projection/styles/transform.mjs.map +1 -1
- package/dist/es/projection/utils/has-transform.mjs +1 -0
- package/dist/es/projection/utils/has-transform.mjs.map +1 -1
- package/dist/es/render/dom/parse-transform.mjs +4 -2
- package/dist/es/render/dom/parse-transform.mjs.map +1 -1
- package/dist/es/render/svg/utils/scrape-motion-values.mjs +7 -2
- package/dist/es/render/svg/utils/scrape-motion-values.mjs.map +1 -1
- package/dist/es/render/utils/keys-transform.mjs +1 -0
- package/dist/es/render/utils/keys-transform.mjs.map +1 -1
- package/dist/es/utils/stagger.mjs +39 -6
- package/dist/es/utils/stagger.mjs.map +1 -1
- package/dist/es/value/types/complex/index.mjs +3 -2
- package/dist/es/value/types/complex/index.mjs.map +1 -1
- package/dist/es/value/utils/follow.mjs +19 -2
- package/dist/es/value/utils/follow.mjs.map +1 -1
- package/dist/index.d.ts +43 -6
- package/dist/motion-dom.dev.js +257 -106
- package/dist/motion-dom.js +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/motion-dom.dev.js
CHANGED
|
@@ -249,8 +249,9 @@
|
|
|
249
249
|
const VAR_TOKEN = "var";
|
|
250
250
|
const VAR_FUNCTION_TOKEN = "var(";
|
|
251
251
|
const SPLIT_TOKEN = "${}";
|
|
252
|
-
// this regex consists of the `singleCssVariableRegex|rgbHSLValueRegex|digitRegex
|
|
253
|
-
|
|
252
|
+
// this regex consists of the `singleCssVariableRegex|rgbHSLValueRegex|digitRegex`.
|
|
253
|
+
// The lookahead skips digits in function names, like the 3 in matrix3d(.
|
|
254
|
+
const complexRegex = /var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)(?![a-z]*\()/giu;
|
|
254
255
|
/**
|
|
255
256
|
* Whether analyseComplexValue(value) would find any values, without
|
|
256
257
|
* tokenising the string. CSS variables are resolved before this is
|
|
@@ -2192,6 +2193,7 @@
|
|
|
2192
2193
|
translateY: 5,
|
|
2193
2194
|
scaleX: 0,
|
|
2194
2195
|
scaleY: 3,
|
|
2196
|
+
scaleZ: () => 1,
|
|
2195
2197
|
scale: (v) => (Math.abs(v[0]) + Math.abs(v[3])) / 2,
|
|
2196
2198
|
rotate,
|
|
2197
2199
|
rotateZ: rotate,
|
|
@@ -2206,8 +2208,8 @@
|
|
|
2206
2208
|
return angle;
|
|
2207
2209
|
};
|
|
2208
2210
|
const rotateZ = rotate;
|
|
2209
|
-
const scaleX = (v) => Math.
|
|
2210
|
-
const scaleY = (v) => Math.
|
|
2211
|
+
const scaleX = (v) => Math.hypot(v[0], v[1]);
|
|
2212
|
+
const scaleY = (v) => Math.hypot(v[4], v[5]);
|
|
2211
2213
|
const matrix3dParsers = {
|
|
2212
2214
|
x: 12,
|
|
2213
2215
|
y: 13,
|
|
@@ -2217,6 +2219,7 @@
|
|
|
2217
2219
|
translateZ: 14,
|
|
2218
2220
|
scaleX,
|
|
2219
2221
|
scaleY,
|
|
2222
|
+
scaleZ: (v) => Math.hypot(v[8], v[9], v[10]),
|
|
2220
2223
|
scale: (v) => (scaleX(v) + scaleY(v)) / 2,
|
|
2221
2224
|
rotateX: (v) => rebaseAngle(radToDeg(Math.atan2(v[6], v[5]))),
|
|
2222
2225
|
rotateY: (v) => rebaseAngle(radToDeg(Math.atan2(-v[2], v[0]))),
|
|
@@ -2276,6 +2279,7 @@
|
|
|
2276
2279
|
"scale",
|
|
2277
2280
|
"scaleX",
|
|
2278
2281
|
"scaleY",
|
|
2282
|
+
"scaleZ",
|
|
2279
2283
|
"rotate",
|
|
2280
2284
|
"rotateX",
|
|
2281
2285
|
"rotateY",
|
|
@@ -3235,6 +3239,7 @@
|
|
|
3235
3239
|
constructor(options) {
|
|
3236
3240
|
const element = getOwner(options).current;
|
|
3237
3241
|
const { driver = frameloopDriver } = options;
|
|
3242
|
+
let animation;
|
|
3238
3243
|
/**
|
|
3239
3244
|
* Before JSAnimation replaces the type with its generator.
|
|
3240
3245
|
*/
|
|
@@ -3264,11 +3269,12 @@
|
|
|
3264
3269
|
stop: () => {
|
|
3265
3270
|
js.stop();
|
|
3266
3271
|
const group = getGroup(element);
|
|
3267
|
-
group
|
|
3272
|
+
group && !group.isFinishing && group.release(animation);
|
|
3268
3273
|
},
|
|
3269
3274
|
};
|
|
3270
3275
|
};
|
|
3271
3276
|
super(options);
|
|
3277
|
+
animation = this;
|
|
3272
3278
|
this.canAccelerate = canAccelerate;
|
|
3273
3279
|
/**
|
|
3274
3280
|
* stop is bound in JSAnimation, so wrap it rather than override.
|
|
@@ -3424,8 +3430,14 @@
|
|
|
3424
3430
|
}
|
|
3425
3431
|
return super.time;
|
|
3426
3432
|
}
|
|
3433
|
+
/**
|
|
3434
|
+
* A JS animation sets its motion value from a seek on its next tick.
|
|
3435
|
+
* This doesn't tick, so set it now, rather than leave it to be set
|
|
3436
|
+
* when this next stops.
|
|
3437
|
+
*/
|
|
3427
3438
|
set time(newTime) {
|
|
3428
3439
|
super.time = newTime;
|
|
3440
|
+
this.isAccelerated() && this.sync();
|
|
3429
3441
|
}
|
|
3430
3442
|
/**
|
|
3431
3443
|
* Scroll timelines set time every frame, so run these on the main
|
|
@@ -3453,6 +3465,7 @@
|
|
|
3453
3465
|
let segments = [];
|
|
3454
3466
|
let needsBuild = false;
|
|
3455
3467
|
let isScheduled = false;
|
|
3468
|
+
let isEnded = false;
|
|
3456
3469
|
let hasChurned = false;
|
|
3457
3470
|
let lastChurn = -Infinity;
|
|
3458
3471
|
const has = (key) => {
|
|
@@ -3569,8 +3582,19 @@
|
|
|
3569
3582
|
for (const track of moving) {
|
|
3570
3583
|
const values = at.map((t) => track.numberAt(t));
|
|
3571
3584
|
const [first] = values;
|
|
3572
|
-
const
|
|
3573
|
-
const
|
|
3585
|
+
const changes = values.map((value) => value - first);
|
|
3586
|
+
const end = changes[changes.length - 1];
|
|
3587
|
+
/**
|
|
3588
|
+
* A value that ends only a tiny way from where it started, as
|
|
3589
|
+
* a round trip does if it's built just after it starts, or
|
|
3590
|
+
* from a float residue, ends where it started. Dividing by
|
|
3591
|
+
* that tiny range would stretch the easing to values the
|
|
3592
|
+
* compositor can't render.
|
|
3593
|
+
*/
|
|
3594
|
+
const range = changes.some((change) => Math.abs(change) * easingTolerance > Math.abs(end))
|
|
3595
|
+
? 0
|
|
3596
|
+
: end;
|
|
3597
|
+
const progress = changes.map((change) => range ? change / range : change);
|
|
3574
3598
|
/**
|
|
3575
3599
|
* A value that doesn't change, like one still in its delay,
|
|
3576
3600
|
* fits any easing. One that changes but ends where it started
|
|
@@ -3872,6 +3896,18 @@
|
|
|
3872
3896
|
}
|
|
3873
3897
|
return true;
|
|
3874
3898
|
};
|
|
3899
|
+
/**
|
|
3900
|
+
* If no animations are left, write where they got to and cancel the
|
|
3901
|
+
* WAAPI animations. Returns whether the group ended.
|
|
3902
|
+
*/
|
|
3903
|
+
const end = () => {
|
|
3904
|
+
if (tracks.size)
|
|
3905
|
+
return false;
|
|
3906
|
+
isEnded = true;
|
|
3907
|
+
transformGroups.delete(element);
|
|
3908
|
+
group.isJS || stop();
|
|
3909
|
+
return true;
|
|
3910
|
+
};
|
|
3875
3911
|
const build = () => {
|
|
3876
3912
|
const now = time.now();
|
|
3877
3913
|
/**
|
|
@@ -3899,15 +3935,14 @@
|
|
|
3899
3935
|
group.isFinishing = false;
|
|
3900
3936
|
}
|
|
3901
3937
|
isScheduled = false;
|
|
3938
|
+
if (isEnded)
|
|
3939
|
+
return;
|
|
3902
3940
|
tracks.forEach(({ state }, track) => {
|
|
3903
3941
|
if (state === "idle" || state === "finished")
|
|
3904
3942
|
tracks.delete(track);
|
|
3905
3943
|
});
|
|
3906
|
-
if (
|
|
3907
|
-
transformGroups.delete(element);
|
|
3908
|
-
group.isJS || stop();
|
|
3944
|
+
if (end())
|
|
3909
3945
|
return;
|
|
3910
|
-
}
|
|
3911
3946
|
for (const track of tracks) {
|
|
3912
3947
|
if (!track.canAccelerate)
|
|
3913
3948
|
return group.demote(true);
|
|
@@ -3939,6 +3974,8 @@
|
|
|
3939
3974
|
isJS: false,
|
|
3940
3975
|
isFinishing: false,
|
|
3941
3976
|
schedule(build_, isChurn) {
|
|
3977
|
+
if (isEnded)
|
|
3978
|
+
return;
|
|
3942
3979
|
needsBuild || (needsBuild = build_);
|
|
3943
3980
|
hasChurned || (hasChurned = !!isChurn);
|
|
3944
3981
|
/**
|
|
@@ -3953,6 +3990,21 @@
|
|
|
3953
3990
|
: queueMicrotask(build);
|
|
3954
3991
|
}
|
|
3955
3992
|
},
|
|
3993
|
+
/**
|
|
3994
|
+
* End the group now, rather than when it next builds, so the
|
|
3995
|
+
* element's transform is the caller's again as soon as its last
|
|
3996
|
+
* animation is stopped.
|
|
3997
|
+
*/
|
|
3998
|
+
release(track) {
|
|
3999
|
+
/**
|
|
4000
|
+
* Only drop the stopped animation. Others can be idle because
|
|
4001
|
+
* they're part way through play(), and are about to run.
|
|
4002
|
+
*/
|
|
4003
|
+
const { state } = track;
|
|
4004
|
+
if (state === "idle" || state === "finished")
|
|
4005
|
+
tracks.delete(track);
|
|
4006
|
+
end() || group.schedule(true);
|
|
4007
|
+
},
|
|
3956
4008
|
/**
|
|
3957
4009
|
* An outside write. Rebuild once, but if it keeps happening, move
|
|
3958
4010
|
* to the main thread.
|
|
@@ -3967,7 +4019,7 @@
|
|
|
3967
4019
|
}
|
|
3968
4020
|
},
|
|
3969
4021
|
demote(canReturn) {
|
|
3970
|
-
if (group.isJS)
|
|
4022
|
+
if (group.isJS || isEnded)
|
|
3971
4023
|
return;
|
|
3972
4024
|
/**
|
|
3973
4025
|
* Unless only another animation is holding the group on the
|
|
@@ -4974,11 +5026,11 @@
|
|
|
4974
5026
|
}
|
|
4975
5027
|
return sample({ x: tx, y: ty }, { x: 0, y: 0 });
|
|
4976
5028
|
},
|
|
4977
|
-
|
|
5029
|
+
animateValues(getValue, target, transition, delay, animations) {
|
|
4978
5030
|
if (!("x" in target || "y" in target))
|
|
4979
5031
|
return;
|
|
4980
|
-
const xValue =
|
|
4981
|
-
const yValue =
|
|
5032
|
+
const xValue = getValue("x");
|
|
5033
|
+
const yValue = getValue("y");
|
|
4982
5034
|
const xRaw = target.x;
|
|
4983
5035
|
const yRaw = target.y;
|
|
4984
5036
|
const xFrom = (Array.isArray(xRaw) && xRaw[0] != null
|
|
@@ -5001,7 +5053,7 @@
|
|
|
5001
5053
|
// concurrent rotate animation composes and nothing accumulates
|
|
5002
5054
|
// on interrupt.
|
|
5003
5055
|
const pathRotationValue = interpolate(0).rotate !== undefined
|
|
5004
|
-
?
|
|
5056
|
+
? getValue("pathRotation")
|
|
5005
5057
|
: undefined;
|
|
5006
5058
|
const pathTransition = {
|
|
5007
5059
|
delay,
|
|
@@ -5211,7 +5263,9 @@
|
|
|
5211
5263
|
const path = transition?.path;
|
|
5212
5264
|
if (path) {
|
|
5213
5265
|
// path mutates `target` to claim x/y; loop below skips them.
|
|
5214
|
-
path.
|
|
5266
|
+
path.animateValues
|
|
5267
|
+
? path.animateValues((key) => visualElement.getValue(key, visualElement.latestValues[key] ?? 0), target, transition, delay, animations)
|
|
5268
|
+
: path.animateVisualElement?.(visualElement, target, transition, delay, animations);
|
|
5215
5269
|
}
|
|
5216
5270
|
for (const key in target) {
|
|
5217
5271
|
const value = visualElement.getValue(key, visualElement.latestValues[key] ?? null);
|
|
@@ -5670,8 +5724,16 @@
|
|
|
5670
5724
|
*/
|
|
5671
5725
|
function animateValues(getValue, keyframes, transition = {}, element) {
|
|
5672
5726
|
const animations = [];
|
|
5673
|
-
const { velocity } = transition;
|
|
5727
|
+
const { velocity, path } = transition;
|
|
5674
5728
|
const reduceMotion = transition.reduceMotion ?? element?.shouldReduceMotion;
|
|
5729
|
+
/**
|
|
5730
|
+
* Only elements have x/y to move along a path. path claims them by
|
|
5731
|
+
* deleting them, so hand it a copy.
|
|
5732
|
+
*/
|
|
5733
|
+
if (path?.animateValues && element) {
|
|
5734
|
+
keyframes = { ...keyframes };
|
|
5735
|
+
path.animateValues(getValue, keyframes, transition, 0, animations);
|
|
5736
|
+
}
|
|
5675
5737
|
for (const key in keyframes) {
|
|
5676
5738
|
if (key === "transition" || key === "transitionEnd")
|
|
5677
5739
|
continue;
|
|
@@ -6276,7 +6338,7 @@
|
|
|
6276
6338
|
}
|
|
6277
6339
|
}
|
|
6278
6340
|
const addSVGValue = (element, state, key, value) => {
|
|
6279
|
-
if (key.startsWith("path")) {
|
|
6341
|
+
if (key.startsWith("path") && !transformProps.has(key)) {
|
|
6280
6342
|
return addSVGPathValue(element, state, key, value);
|
|
6281
6343
|
}
|
|
6282
6344
|
else if (key.startsWith("attr")) {
|
|
@@ -6377,6 +6439,7 @@
|
|
|
6377
6439
|
values.rotate ||
|
|
6378
6440
|
values.rotateX ||
|
|
6379
6441
|
values.rotateY ||
|
|
6442
|
+
values.rotateZ ||
|
|
6380
6443
|
values.skewX ||
|
|
6381
6444
|
values.skewY);
|
|
6382
6445
|
}
|
|
@@ -7060,13 +7123,46 @@
|
|
|
7060
7123
|
return from === "last" ? lastIndex : lastIndex / 2;
|
|
7061
7124
|
}
|
|
7062
7125
|
}
|
|
7063
|
-
function stagger(duration = 0.1, { startDelay = 0, from = 0, ease } = {}) {
|
|
7126
|
+
function stagger(duration = 0.1, { startDelay = 0, from = 0, ease, grid } = {}) {
|
|
7127
|
+
/**
|
|
7128
|
+
* Distances from the origin for each element count. The final entry
|
|
7129
|
+
* holds the distance used to normalise easing.
|
|
7130
|
+
*/
|
|
7131
|
+
const cache = {};
|
|
7064
7132
|
return (i, total) => {
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
const
|
|
7133
|
+
let distances = cache[total];
|
|
7134
|
+
if (!distances) {
|
|
7135
|
+
const [columns, rows] = grid || [Infinity, 1];
|
|
7136
|
+
const lastX = Math.min(columns, total) - 1;
|
|
7137
|
+
const lastY = Math.max(rows, Math.ceil(total / columns)) - 1;
|
|
7138
|
+
const isIndex = typeof from === "number";
|
|
7139
|
+
const scale = from === "first" ? 0 : from === "last" ? 1 : 0.5;
|
|
7140
|
+
const originX = isIndex ? from % columns : lastX * scale;
|
|
7141
|
+
const originY = isIndex ? Math.floor(from / columns) : lastY * scale;
|
|
7142
|
+
distances = cache[total] = [];
|
|
7143
|
+
for (let j = 0; j < total; j++) {
|
|
7144
|
+
const x = j % columns;
|
|
7145
|
+
const y = Math.floor(j / columns);
|
|
7146
|
+
const edgeX = Math.min(x, lastX - x);
|
|
7147
|
+
const edgeY = Math.min(y, lastY - y);
|
|
7148
|
+
if (from === "random") {
|
|
7149
|
+
// Inside-out shuffle, so each element gets a distinct step
|
|
7150
|
+
const k = (Math.random() * (j + 1)) | 0;
|
|
7151
|
+
distances[j] = distances[k];
|
|
7152
|
+
distances[k] = j;
|
|
7153
|
+
}
|
|
7154
|
+
else {
|
|
7155
|
+
distances[j] =
|
|
7156
|
+
from === "edges"
|
|
7157
|
+
? Math.min(lastX ? edgeX : edgeY, lastY ? edgeY : edgeX)
|
|
7158
|
+
: Math.hypot(x - originX, y - originY);
|
|
7159
|
+
}
|
|
7160
|
+
}
|
|
7161
|
+
distances.push(grid ? Math.max(...distances) : total);
|
|
7162
|
+
}
|
|
7163
|
+
let delay = duration * distances[i];
|
|
7164
|
+
const maxDelay = duration * distances[total];
|
|
7165
|
+
if (ease && maxDelay) {
|
|
7070
7166
|
const easingFunction = motionUtils.easingDefinitionToFunction(ease);
|
|
7071
7167
|
delay = easingFunction(delay / maxDelay) * maxDelay;
|
|
7072
7168
|
}
|
|
@@ -7300,7 +7396,7 @@
|
|
|
7300
7396
|
}, stopAnimation);
|
|
7301
7397
|
if (isMotionValue(source)) {
|
|
7302
7398
|
let skipNextAnimation = options.skipInitialAnimation === true;
|
|
7303
|
-
const
|
|
7399
|
+
const onSourceChange = (v) => {
|
|
7304
7400
|
if (skipNextAnimation) {
|
|
7305
7401
|
skipNextAnimation = false;
|
|
7306
7402
|
value.jump(parseValue(v, unit), false);
|
|
@@ -7308,11 +7404,28 @@
|
|
|
7308
7404
|
else {
|
|
7309
7405
|
value.set(parseValue(v, unit));
|
|
7310
7406
|
}
|
|
7311
|
-
}
|
|
7407
|
+
};
|
|
7408
|
+
const removeSourceOnChange = source.on("change", onSourceChange);
|
|
7409
|
+
/**
|
|
7410
|
+
* Catch up on a change made before we subscribed, for instance
|
|
7411
|
+
* between a React render reading the source and the effect
|
|
7412
|
+
* attaching to it. Subtracting is falsy for equal or non-numeric
|
|
7413
|
+
* (NaN) values.
|
|
7414
|
+
*/
|
|
7415
|
+
const latest = source.get();
|
|
7416
|
+
if (asNumber(latest) - asNumber(value.get()))
|
|
7417
|
+
onSourceChange(latest);
|
|
7312
7418
|
const removeValueOnDestroy = value.on("destroy", removeSourceOnChange);
|
|
7419
|
+
/**
|
|
7420
|
+
* Stop our animation on detach, otherwise a re-attach (new
|
|
7421
|
+
* options, Strict Mode) starts a second animation that fights
|
|
7422
|
+
* this orphaned one. The catch-up above resumes from the
|
|
7423
|
+
* current value and velocity.
|
|
7424
|
+
*/
|
|
7313
7425
|
return () => {
|
|
7314
7426
|
removeSourceOnChange();
|
|
7315
7427
|
removeValueOnDestroy();
|
|
7428
|
+
stopAnimation();
|
|
7316
7429
|
};
|
|
7317
7430
|
}
|
|
7318
7431
|
return stopAnimation;
|
|
@@ -9475,8 +9588,13 @@
|
|
|
9475
9588
|
function scrapeMotionValuesFromProps(props, prevProps, visualElement) {
|
|
9476
9589
|
const newValues = scrapeMotionValuesFromProps$1(props, prevProps, visualElement);
|
|
9477
9590
|
for (const key in props) {
|
|
9478
|
-
|
|
9479
|
-
|
|
9591
|
+
/**
|
|
9592
|
+
* A MotionValue child is rendered as text content by
|
|
9593
|
+
* DOMVisualElement, so it mustn't also be written as an attribute.
|
|
9594
|
+
*/
|
|
9595
|
+
if (key !== "children" &&
|
|
9596
|
+
(isMotionValue(props[key]) ||
|
|
9597
|
+
isMotionValue(prevProps[key]))) {
|
|
9480
9598
|
const targetKey = transformPropOrder.indexOf(key) !== -1
|
|
9481
9599
|
? "attr" + key.charAt(0).toUpperCase() + key.substring(1)
|
|
9482
9600
|
: key;
|
|
@@ -10107,7 +10225,7 @@
|
|
|
10107
10225
|
transform += `scale(${1 / treeScale.x}, ${1 / treeScale.y}) `;
|
|
10108
10226
|
}
|
|
10109
10227
|
if (latestTransform) {
|
|
10110
|
-
const { transformPerspective, rotate, pathRotation, rotateX, rotateY, skewX, skewY, } = latestTransform;
|
|
10228
|
+
const { transformPerspective, rotate, pathRotation, rotateX, rotateY, rotateZ, skewX, skewY, } = latestTransform;
|
|
10111
10229
|
if (transformPerspective)
|
|
10112
10230
|
transform = `perspective(${transformPerspective}px) ${transform}`;
|
|
10113
10231
|
if (rotate)
|
|
@@ -10119,6 +10237,8 @@
|
|
|
10119
10237
|
transform += `rotateX(${rotateX}deg) `;
|
|
10120
10238
|
if (rotateY)
|
|
10121
10239
|
transform += `rotateY(${rotateY}deg) `;
|
|
10240
|
+
if (rotateZ)
|
|
10241
|
+
transform += `rotateZ(${rotateZ}deg) `;
|
|
10122
10242
|
if (skewX)
|
|
10123
10243
|
transform += `skewX(${skewX}deg) `;
|
|
10124
10244
|
if (skewY)
|
|
@@ -10137,6 +10257,15 @@
|
|
|
10137
10257
|
}
|
|
10138
10258
|
|
|
10139
10259
|
const numBorders = cornerRadiusProps.length;
|
|
10260
|
+
const mixedTransforms = [
|
|
10261
|
+
"rotate",
|
|
10262
|
+
"rotateX",
|
|
10263
|
+
"rotateY",
|
|
10264
|
+
"rotateZ",
|
|
10265
|
+
"skewX",
|
|
10266
|
+
"skewY",
|
|
10267
|
+
];
|
|
10268
|
+
const numMixedTransforms = mixedTransforms.length;
|
|
10140
10269
|
const isPx = (value) => typeof value === "number" || px.test(value);
|
|
10141
10270
|
function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnlyMember) {
|
|
10142
10271
|
if (shouldCrossfadeOpacity) {
|
|
@@ -10171,10 +10300,14 @@
|
|
|
10171
10300
|
}
|
|
10172
10301
|
}
|
|
10173
10302
|
/**
|
|
10174
|
-
* Mix rotation
|
|
10303
|
+
* Mix rotation and skew. These can't be projected, so mix them every
|
|
10304
|
+
* frame rather than leaving them frozen at the animation-start snapshot.
|
|
10175
10305
|
*/
|
|
10176
|
-
|
|
10177
|
-
|
|
10306
|
+
for (let i = 0; i < numMixedTransforms; i++) {
|
|
10307
|
+
const key = mixedTransforms[i];
|
|
10308
|
+
if (follow[key] || lead[key]) {
|
|
10309
|
+
target[key] = mixNumber$1(follow[key] || 0, lead[key] || 0, progress);
|
|
10310
|
+
}
|
|
10178
10311
|
}
|
|
10179
10312
|
}
|
|
10180
10313
|
function getRadius(values, radiusName) {
|
|
@@ -10624,82 +10757,92 @@
|
|
|
10624
10757
|
if (layoutId) {
|
|
10625
10758
|
this.root.registerSharedNode(layoutId, this);
|
|
10626
10759
|
}
|
|
10627
|
-
|
|
10628
|
-
|
|
10629
|
-
|
|
10630
|
-
|
|
10631
|
-
|
|
10632
|
-
|
|
10633
|
-
|
|
10634
|
-
|
|
10635
|
-
|
|
10760
|
+
this.addLayoutListener();
|
|
10761
|
+
}
|
|
10762
|
+
/**
|
|
10763
|
+
* Only register the layout animation handler if this node requires
|
|
10764
|
+
* layout animation. This is called on mount, and again whenever options
|
|
10765
|
+
* change, as `layout` or `layoutId` may be enabled after mount.
|
|
10766
|
+
*/
|
|
10767
|
+
addLayoutListener() {
|
|
10768
|
+
const { layoutId, layout, visualElement, animate } = this.options;
|
|
10769
|
+
if (!this.instance ||
|
|
10770
|
+
this.hasLayoutListener ||
|
|
10771
|
+
animate === false ||
|
|
10772
|
+
!visualElement ||
|
|
10773
|
+
!(layoutId || layout))
|
|
10774
|
+
return;
|
|
10775
|
+
this.hasLayoutListener = true;
|
|
10776
|
+
this.addEventListener("didUpdate", ({ delta, hasLayoutChanged, hasRelativeLayoutChanged, layout: newLayout, }) => {
|
|
10777
|
+
if (this.isAnimationBlocked) {
|
|
10778
|
+
this.target = undefined;
|
|
10779
|
+
this.relativeTarget = undefined;
|
|
10780
|
+
return;
|
|
10781
|
+
}
|
|
10782
|
+
// TODO: Check here if an animation exists
|
|
10783
|
+
const layoutTransition = this.options.transition ||
|
|
10784
|
+
visualElement.getDefaultTransition() ||
|
|
10785
|
+
defaultLayoutTransition;
|
|
10786
|
+
const { onLayoutAnimationStart, onLayoutAnimationComplete, } = visualElement.getProps();
|
|
10787
|
+
/**
|
|
10788
|
+
* The target layout of the element might stay the same,
|
|
10789
|
+
* but its position relative to its parent has changed.
|
|
10790
|
+
*/
|
|
10791
|
+
const hasTargetChanged = !this.targetLayout ||
|
|
10792
|
+
!boxEqualsRounded(this.targetLayout, newLayout);
|
|
10793
|
+
/*
|
|
10794
|
+
* Note: Disabled to fix relative animations always triggering new
|
|
10795
|
+
* layout animations. If this causes further issues, we can try
|
|
10796
|
+
* a different approach to detecting relative target changes.
|
|
10797
|
+
*/
|
|
10798
|
+
// || hasRelativeLayoutChanged
|
|
10799
|
+
/**
|
|
10800
|
+
* If the layout hasn't seemed to have changed, it might be that the
|
|
10801
|
+
* element is visually in the same place in the document but its position
|
|
10802
|
+
* relative to its parent has indeed changed. So here we check for that.
|
|
10803
|
+
*/
|
|
10804
|
+
const hasOnlyRelativeTargetChanged = !hasLayoutChanged && hasRelativeLayoutChanged;
|
|
10805
|
+
if (this.options.layoutRoot ||
|
|
10806
|
+
this.resumeFrom ||
|
|
10807
|
+
hasOnlyRelativeTargetChanged ||
|
|
10808
|
+
(hasLayoutChanged &&
|
|
10809
|
+
(hasTargetChanged || !this.currentAnimation))) {
|
|
10810
|
+
if (this.resumeFrom) {
|
|
10811
|
+
this.resumingFrom = this.resumeFrom;
|
|
10812
|
+
this.resumingFrom.resumingFrom = undefined;
|
|
10813
|
+
}
|
|
10814
|
+
const animationOptions = {
|
|
10815
|
+
...getValueTransition(layoutTransition, "layout"),
|
|
10816
|
+
onPlay: onLayoutAnimationStart,
|
|
10817
|
+
onComplete: onLayoutAnimationComplete,
|
|
10818
|
+
};
|
|
10819
|
+
if (visualElement.shouldReduceMotion ||
|
|
10820
|
+
this.options.layoutRoot) {
|
|
10821
|
+
animationOptions.delay = 0;
|
|
10822
|
+
animationOptions.type = false;
|
|
10636
10823
|
}
|
|
10637
|
-
|
|
10638
|
-
const layoutTransition = this.options.transition ||
|
|
10639
|
-
visualElement.getDefaultTransition() ||
|
|
10640
|
-
defaultLayoutTransition;
|
|
10641
|
-
const { onLayoutAnimationStart, onLayoutAnimationComplete, } = visualElement.getProps();
|
|
10824
|
+
this.startAnimation(animationOptions);
|
|
10642
10825
|
/**
|
|
10643
|
-
*
|
|
10644
|
-
*
|
|
10645
|
-
*/
|
|
10646
|
-
const hasTargetChanged = !this.targetLayout ||
|
|
10647
|
-
!boxEqualsRounded(this.targetLayout, newLayout);
|
|
10648
|
-
/*
|
|
10649
|
-
* Note: Disabled to fix relative animations always triggering new
|
|
10650
|
-
* layout animations. If this causes further issues, we can try
|
|
10651
|
-
* a different approach to detecting relative target changes.
|
|
10826
|
+
* Set animation origin after starting animation to avoid layout jump
|
|
10827
|
+
* caused by stopping previous layout animation
|
|
10652
10828
|
*/
|
|
10653
|
-
|
|
10829
|
+
this.setAnimationOrigin(delta, hasOnlyRelativeTargetChanged, animationOptions.path);
|
|
10830
|
+
}
|
|
10831
|
+
else {
|
|
10654
10832
|
/**
|
|
10655
|
-
* If the layout hasn't
|
|
10656
|
-
*
|
|
10657
|
-
*
|
|
10833
|
+
* If the layout hasn't changed and we have an animation that hasn't started yet,
|
|
10834
|
+
* finish it immediately. Otherwise it will be animating from a location
|
|
10835
|
+
* that was probably never committed to screen and look like a jumpy box.
|
|
10658
10836
|
*/
|
|
10659
|
-
|
|
10660
|
-
|
|
10661
|
-
this.resumeFrom ||
|
|
10662
|
-
hasOnlyRelativeTargetChanged ||
|
|
10663
|
-
(hasLayoutChanged &&
|
|
10664
|
-
(hasTargetChanged || !this.currentAnimation))) {
|
|
10665
|
-
if (this.resumeFrom) {
|
|
10666
|
-
this.resumingFrom = this.resumeFrom;
|
|
10667
|
-
this.resumingFrom.resumingFrom = undefined;
|
|
10668
|
-
}
|
|
10669
|
-
const animationOptions = {
|
|
10670
|
-
...getValueTransition(layoutTransition, "layout"),
|
|
10671
|
-
onPlay: onLayoutAnimationStart,
|
|
10672
|
-
onComplete: onLayoutAnimationComplete,
|
|
10673
|
-
};
|
|
10674
|
-
if (visualElement.shouldReduceMotion ||
|
|
10675
|
-
this.options.layoutRoot) {
|
|
10676
|
-
animationOptions.delay = 0;
|
|
10677
|
-
animationOptions.type = false;
|
|
10678
|
-
}
|
|
10679
|
-
this.startAnimation(animationOptions);
|
|
10680
|
-
/**
|
|
10681
|
-
* Set animation origin after starting animation to avoid layout jump
|
|
10682
|
-
* caused by stopping previous layout animation
|
|
10683
|
-
*/
|
|
10684
|
-
this.setAnimationOrigin(delta, hasOnlyRelativeTargetChanged, animationOptions
|
|
10685
|
-
.path);
|
|
10837
|
+
if (!hasLayoutChanged) {
|
|
10838
|
+
finishAnimation(this);
|
|
10686
10839
|
}
|
|
10687
|
-
|
|
10688
|
-
|
|
10689
|
-
* If the layout hasn't changed and we have an animation that hasn't started yet,
|
|
10690
|
-
* finish it immediately. Otherwise it will be animating from a location
|
|
10691
|
-
* that was probably never committed to screen and look like a jumpy box.
|
|
10692
|
-
*/
|
|
10693
|
-
if (!hasLayoutChanged) {
|
|
10694
|
-
finishAnimation(this);
|
|
10695
|
-
}
|
|
10696
|
-
if (this.isLead() && this.options.onExitComplete) {
|
|
10697
|
-
this.options.onExitComplete();
|
|
10698
|
-
}
|
|
10840
|
+
if (this.isLead() && this.options.onExitComplete) {
|
|
10841
|
+
this.options.onExitComplete();
|
|
10699
10842
|
}
|
|
10700
|
-
|
|
10701
|
-
|
|
10702
|
-
}
|
|
10843
|
+
}
|
|
10844
|
+
this.targetLayout = newLayout;
|
|
10845
|
+
});
|
|
10703
10846
|
}
|
|
10704
10847
|
unmount() {
|
|
10705
10848
|
this.options.layoutId && this.willUpdate();
|
|
@@ -10709,6 +10852,7 @@
|
|
|
10709
10852
|
this.parent && this.parent.children.delete(this);
|
|
10710
10853
|
this.instance = undefined;
|
|
10711
10854
|
this.eventHandlers.clear();
|
|
10855
|
+
this.hasLayoutListener = false;
|
|
10712
10856
|
cancelFrame(this.updateProjection);
|
|
10713
10857
|
}
|
|
10714
10858
|
// only on the root
|
|
@@ -10879,7 +11023,16 @@
|
|
|
10879
11023
|
}
|
|
10880
11024
|
clearAllSnapshots() {
|
|
10881
11025
|
this.nodes.forEach(clearSnapshot);
|
|
10882
|
-
|
|
11026
|
+
/**
|
|
11027
|
+
* A stack's last member can unmount while a replacement with the
|
|
11028
|
+
* same layoutId mounts in the same commit, so the stack (and its
|
|
11029
|
+
* lead) must outlive the unmount for the replacement to resume
|
|
11030
|
+
* from it. By now that handoff has happened, so stacks that are
|
|
11031
|
+
* still empty only retain unmounted nodes and can be released.
|
|
11032
|
+
*/
|
|
11033
|
+
this.sharedNodes.forEach((stack, layoutId) => stack.members.length
|
|
11034
|
+
? stack.removeLeadSnapshot()
|
|
11035
|
+
: this.sharedNodes.delete(layoutId));
|
|
10883
11036
|
}
|
|
10884
11037
|
scheduleUpdateProjection() {
|
|
10885
11038
|
if (!this.projectionUpdateScheduled) {
|
|
@@ -11103,6 +11256,7 @@
|
|
|
11103
11256
|
...options,
|
|
11104
11257
|
crossfade: options.crossfade !== undefined ? options.crossfade : true,
|
|
11105
11258
|
};
|
|
11259
|
+
this.addLayoutListener();
|
|
11106
11260
|
}
|
|
11107
11261
|
clearMeasurements() {
|
|
11108
11262
|
this.scroll = undefined;
|
|
@@ -12032,9 +12186,6 @@
|
|
|
12032
12186
|
function resetSkewAndRotation(node) {
|
|
12033
12187
|
node.resetSkewAndRotation();
|
|
12034
12188
|
}
|
|
12035
|
-
function removeLeadSnapshots(stack) {
|
|
12036
|
-
stack.removeLeadSnapshot();
|
|
12037
|
-
}
|
|
12038
12189
|
function mixAxisDeltaLinear(output, delta, p) {
|
|
12039
12190
|
output.translate = mixNumber$1(delta.translate, 0, p);
|
|
12040
12191
|
output.scale = mixNumber$1(delta.scale, 1, p);
|