motion-dom 14.6.0 → 14.7.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 +574 -580
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/AsyncMotionValueAnimation.mjs +3 -6
- package/dist/es/animation/AsyncMotionValueAnimation.mjs.map +1 -1
- package/dist/es/animation/JSAnimation.mjs +18 -30
- package/dist/es/animation/JSAnimation.mjs.map +1 -1
- package/dist/es/animation/NativeAnimation.mjs +4 -4
- package/dist/es/animation/NativeAnimation.mjs.map +1 -1
- package/dist/es/animation/animate/effects.mjs +5 -2
- package/dist/es/animation/animate/effects.mjs.map +1 -1
- package/dist/es/animation/generators/inertia.mjs +3 -2
- package/dist/es/animation/generators/inertia.mjs.map +1 -1
- package/dist/es/animation/generators/spring.mjs +40 -44
- package/dist/es/animation/generators/spring.mjs.map +1 -1
- package/dist/es/animation/interfaces/visual-element-target.mjs +1 -1
- package/dist/es/animation/interfaces/visual-element-target.mjs.map +1 -1
- package/dist/es/animation/keyframes/DOMKeyframesResolver.mjs +7 -15
- package/dist/es/animation/keyframes/DOMKeyframesResolver.mjs.map +1 -1
- package/dist/es/animation/keyframes/KeyframesResolver.mjs.map +1 -1
- package/dist/es/animation/utils/can-animate.mjs +1 -0
- package/dist/es/animation/utils/can-animate.mjs.map +1 -1
- package/dist/es/animation/utils/css-variables-conversion.mjs +2 -1
- package/dist/es/animation/utils/css-variables-conversion.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/transforms/TransformAnimation.mjs +45 -21
- package/dist/es/animation/waapi/transforms/TransformAnimation.mjs.map +1 -1
- package/dist/es/animation/waapi/transforms/groups.mjs.map +1 -1
- package/dist/es/animation/waapi/utils/accelerated-values.mjs +4 -1
- package/dist/es/animation/waapi/utils/accelerated-values.mjs.map +1 -1
- package/dist/es/effects/style/transform.mjs +4 -20
- package/dist/es/effects/style/transform.mjs.map +1 -1
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +78 -61
- package/dist/es/gestures/drag/VisualElementDragControls.mjs.map +1 -1
- package/dist/es/gestures/pan/PanSession.mjs +28 -39
- package/dist/es/gestures/pan/PanSession.mjs.map +1 -1
- package/dist/es/index.mjs +1 -1
- package/dist/es/layout/LayoutAnimationBuilder.mjs +2 -2
- package/dist/es/layout/LayoutAnimationBuilder.mjs.map +1 -1
- package/dist/es/projection/animation/mix-values.mjs +3 -11
- package/dist/es/projection/animation/mix-values.mjs.map +1 -1
- package/dist/es/projection/geometry/delta-apply.mjs +10 -6
- package/dist/es/projection/geometry/delta-apply.mjs.map +1 -1
- package/dist/es/projection/geometry/delta-calc.mjs +2 -2
- package/dist/es/projection/geometry/delta-calc.mjs.map +1 -1
- package/dist/es/projection/geometry/delta-remove.mjs +2 -2
- package/dist/es/projection/geometry/delta-remove.mjs.map +1 -1
- package/dist/es/projection/node/HTMLProjectionNode.mjs +1 -1
- package/dist/es/projection/node/HTMLProjectionNode.mjs.map +1 -1
- package/dist/es/projection/node/create-projection-node.mjs +147 -138
- package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
- package/dist/es/projection/styles/transform.mjs +12 -16
- package/dist/es/projection/styles/transform.mjs.map +1 -1
- package/dist/es/projection/utils/has-transform.mjs +16 -2
- package/dist/es/projection/utils/has-transform.mjs.map +1 -1
- package/dist/es/render/VisualElement.mjs +20 -37
- package/dist/es/render/VisualElement.mjs.map +1 -1
- package/dist/es/render/dom/parse-transform.mjs +6 -17
- package/dist/es/render/dom/parse-transform.mjs.map +1 -1
- package/dist/es/render/html/HTMLVisualElement.mjs +2 -1
- package/dist/es/render/html/HTMLVisualElement.mjs.map +1 -1
- package/dist/es/render/html/utils/build-transform.mjs +25 -29
- package/dist/es/render/html/utils/build-transform.mjs.map +1 -1
- package/dist/es/render/utils/animation-state.mjs +57 -13
- package/dist/es/render/utils/animation-state.mjs.map +1 -1
- package/dist/es/utils/interpolate.mjs +2 -1
- package/dist/es/utils/interpolate.mjs.map +1 -1
- package/dist/es/utils/mix/color.mjs +2 -1
- package/dist/es/utils/mix/color.mjs.map +1 -1
- package/dist/es/utils/mix/complex.mjs +4 -4
- package/dist/es/utils/mix/complex.mjs.map +1 -1
- package/dist/es/utils/resolve-elements.mjs.map +1 -1
- package/dist/es/value/index.mjs +13 -34
- package/dist/es/value/index.mjs.map +1 -1
- package/dist/es/value/types/color/hex.mjs +13 -26
- package/dist/es/value/types/color/hex.mjs.map +1 -1
- package/dist/es/value/types/complex/index.mjs +1 -1
- package/dist/es/value/types/complex/index.mjs.map +1 -1
- package/dist/index.d.ts +72 -21
- package/dist/motion-dom.dev.js +558 -573
- 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 +4 -3
|
@@ -26,7 +26,7 @@ import { defaultScaleCorrectors } from '../styles/default-scale-correctors.mjs';
|
|
|
26
26
|
import { buildProjectionTransform } from '../styles/transform.mjs';
|
|
27
27
|
import { eachAxis } from '../utils/each-axis.mjs';
|
|
28
28
|
import { FlatTree } from '../utils/flat-tree.mjs';
|
|
29
|
-
import { hasTransform, hasScale, has2DTranslate } from '../utils/has-transform.mjs';
|
|
29
|
+
import { hasTransform, hasScale, has2DTranslate, hasDistortingTransform, angleTransforms } from '../utils/has-transform.mjs';
|
|
30
30
|
import { globalProjectionState } from './state.mjs';
|
|
31
31
|
import { frame, cancelFrame, frameSteps } from '../../frameloop/frame.mjs';
|
|
32
32
|
import { frameData } from '../../frameloop/frame-data.mjs';
|
|
@@ -36,7 +36,10 @@ const metrics = {
|
|
|
36
36
|
calculatedTargetDeltas: 0,
|
|
37
37
|
calculatedProjections: 0,
|
|
38
38
|
};
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Transforms that distort an element's layout, so must be reset before measuring.
|
|
41
|
+
*/
|
|
42
|
+
const distortingTransforms = ["z", "skew", "skewZ"];
|
|
40
43
|
/**
|
|
41
44
|
* We use 1000 as the animation target as 0-1000 maps better to pixels than 0-1
|
|
42
45
|
* which has a noticeable difference in spring animations
|
|
@@ -54,7 +57,15 @@ function resetDistortingTransform(key, visualElement, values, sharedAnimationVal
|
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Move accelerated transforms back to the main thread. The WAAPI animation
|
|
62
|
+
* hid startUpdate()'s reset of rotations, skews and z, and moving off it
|
|
63
|
+
* writes the whole transform back, so reset them again before this node
|
|
64
|
+
* is measured.
|
|
65
|
+
*/
|
|
66
|
+
const demoteTransforms = (node) => node.instance &&
|
|
67
|
+
transformGroups.get(node.instance)?.demote() &&
|
|
68
|
+
node.resetSkewAndRotation();
|
|
58
69
|
function cancelTreeOptimisedTransformAnimations(projectionNode) {
|
|
59
70
|
projectionNode.hasCheckedOptimisedAppear = true;
|
|
60
71
|
if (projectionNode.root === projectionNode)
|
|
@@ -244,8 +255,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
244
255
|
return this.eventHandlers.get(name).add(handler);
|
|
245
256
|
}
|
|
246
257
|
notifyListeners(name, ...args) {
|
|
247
|
-
|
|
248
|
-
subscriptionManager && subscriptionManager.notify(...args);
|
|
258
|
+
this.eventHandlers.get(name)?.notify(...args);
|
|
249
259
|
}
|
|
250
260
|
hasListeners(name) {
|
|
251
261
|
return this.eventHandlers.has(name);
|
|
@@ -263,7 +273,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
263
273
|
visualElement.mount(instance);
|
|
264
274
|
}
|
|
265
275
|
this.root.nodes.add(this);
|
|
266
|
-
this.parent
|
|
276
|
+
this.parent?.children.add(this);
|
|
267
277
|
if (this.root.hasTreeAnimated && (layout || layoutId)) {
|
|
268
278
|
this.isLayoutDirty = true;
|
|
269
279
|
}
|
|
@@ -281,7 +291,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
281
291
|
return;
|
|
282
292
|
innerWidth = newInnerWidth;
|
|
283
293
|
this.root.updateBlockedByResize = true;
|
|
284
|
-
cancelDelay
|
|
294
|
+
cancelDelay?.();
|
|
285
295
|
cancelDelay = delay(resizeUnblockUpdate, 250);
|
|
286
296
|
if (globalProjectionState.hasAnimatedSinceResize) {
|
|
287
297
|
globalProjectionState.hasAnimatedSinceResize = false;
|
|
@@ -372,9 +382,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
372
382
|
if (!hasLayoutChanged) {
|
|
373
383
|
finishAnimation(this);
|
|
374
384
|
}
|
|
375
|
-
|
|
376
|
-
this.options.onExitComplete();
|
|
377
|
-
}
|
|
385
|
+
this.isLead() && this.options.onExitComplete?.();
|
|
378
386
|
}
|
|
379
387
|
this.targetLayout = newLayout;
|
|
380
388
|
});
|
|
@@ -382,9 +390,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
382
390
|
unmount() {
|
|
383
391
|
this.options.layoutId && this.willUpdate();
|
|
384
392
|
this.root.nodes.remove(this);
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
this.parent && this.parent.children.delete(this);
|
|
393
|
+
this.getStack()?.remove(this);
|
|
394
|
+
this.parent?.children.delete(this);
|
|
388
395
|
this.instance = undefined;
|
|
389
396
|
this.eventHandlers.clear();
|
|
390
397
|
this.hasLayoutListener = false;
|
|
@@ -405,7 +412,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
405
412
|
if (this.isUpdateBlocked())
|
|
406
413
|
return;
|
|
407
414
|
this.isUpdating = true;
|
|
408
|
-
this.nodes
|
|
415
|
+
this.nodes?.forEach(resetSkewAndRotation);
|
|
409
416
|
this.animationId++;
|
|
410
417
|
}
|
|
411
418
|
getTransformTemplate() {
|
|
@@ -415,7 +422,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
415
422
|
willUpdate(shouldNotifyListeners = true) {
|
|
416
423
|
this.root.hasTreeAnimated = true;
|
|
417
424
|
if (this.root.isUpdateBlocked()) {
|
|
418
|
-
this.options.onExitComplete
|
|
425
|
+
this.options.onExitComplete?.();
|
|
419
426
|
return;
|
|
420
427
|
}
|
|
421
428
|
/**
|
|
@@ -632,24 +639,23 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
632
639
|
this.projectionDelta = undefined;
|
|
633
640
|
this.notifyListeners("measure", this.layout.layoutBox);
|
|
634
641
|
const { visualElement } = this.options;
|
|
635
|
-
visualElement
|
|
636
|
-
visualElement.notify("LayoutMeasure", this.layout.layoutBox, prevLayout ? prevLayout.layoutBox : undefined);
|
|
642
|
+
visualElement?.notify("LayoutMeasure", this.layout.layoutBox, prevLayout?.layoutBox);
|
|
637
643
|
}
|
|
638
644
|
updateScroll(phase = "measure") {
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
const isRoot = checkIsScrollRoot(
|
|
645
|
+
const { scroll, instance } = this;
|
|
646
|
+
const { animationId } = this.root;
|
|
647
|
+
if (this.options.layoutScroll &&
|
|
648
|
+
instance &&
|
|
649
|
+
!(scroll &&
|
|
650
|
+
scroll.animationId === animationId &&
|
|
651
|
+
scroll.phase === phase)) {
|
|
652
|
+
const isRoot = checkIsScrollRoot(instance);
|
|
647
653
|
this.scroll = {
|
|
648
|
-
animationId
|
|
654
|
+
animationId,
|
|
649
655
|
phase,
|
|
650
656
|
isRoot,
|
|
651
|
-
offset: measureScroll(
|
|
652
|
-
wasRoot:
|
|
657
|
+
offset: measureScroll(instance),
|
|
658
|
+
wasRoot: scroll ? scroll.isRoot : isRoot,
|
|
653
659
|
};
|
|
654
660
|
}
|
|
655
661
|
}
|
|
@@ -739,10 +745,10 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
739
745
|
}
|
|
740
746
|
return boxWithoutScroll;
|
|
741
747
|
}
|
|
742
|
-
applyTransform(box, transformOnly = false, output, skipOwnTransform) {
|
|
748
|
+
applyTransform(box, transformOnly = false, output, skipOwnTransform, start = 0) {
|
|
743
749
|
const withTransforms = output || createBox();
|
|
744
750
|
copyBoxInto(withTransforms, box);
|
|
745
|
-
for (let i =
|
|
751
|
+
for (let i = start; i < this.path.length; i++) {
|
|
746
752
|
const node = this.path[i];
|
|
747
753
|
if (!transformOnly &&
|
|
748
754
|
node.options.layoutScroll &&
|
|
@@ -914,8 +920,13 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
914
920
|
this.attemptToResolveRelativeTarget = false;
|
|
915
921
|
if (this.options.layoutAnchor !== false &&
|
|
916
922
|
relativeParent &&
|
|
917
|
-
|
|
918
|
-
|
|
923
|
+
(!relativeParent.resumingFrom === !this.resumingFrom ||
|
|
924
|
+
/**
|
|
925
|
+
* Shared layout animations within a layoutRoot
|
|
926
|
+
* animate relative to it.
|
|
927
|
+
*/
|
|
928
|
+
(relativeParent.options.layoutRoot &&
|
|
929
|
+
!relativeParent.resumingFrom)) &&
|
|
919
930
|
!relativeParent.options.layoutScroll &&
|
|
920
931
|
relativeParent.target &&
|
|
921
932
|
this.animationProgress !== 1) {
|
|
@@ -995,7 +1006,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
995
1006
|
* If this section of the tree isn't animating we can
|
|
996
1007
|
* delete our target sources for the following frame.
|
|
997
1008
|
*/
|
|
998
|
-
this.isTreeAnimating = Boolean(
|
|
1009
|
+
this.isTreeAnimating = Boolean(this.parent?.isTreeAnimating ||
|
|
999
1010
|
this.currentAnimation ||
|
|
1000
1011
|
this.pendingAnimation);
|
|
1001
1012
|
if (!this.isTreeAnimating) {
|
|
@@ -1016,8 +1027,17 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1016
1027
|
/**
|
|
1017
1028
|
* Apply all the parent deltas to this box to produce the corrected box. This
|
|
1018
1029
|
* is the layout box, as it will appear on screen as a result of the transforms of its parents.
|
|
1030
|
+
*
|
|
1031
|
+
* A shared target is usually in page space, so ancestor transforms are applied
|
|
1032
|
+
* too. But a target relative to a parent that isn't itself shared (like a
|
|
1033
|
+
* layoutRoot) is in that parent's layout space. So the transforms of the
|
|
1034
|
+
* parent and its ancestors, which move both elements alike, are skipped,
|
|
1035
|
+
* but those of other ancestors (between it and either element) apply.
|
|
1019
1036
|
*/
|
|
1020
|
-
applyTreeDeltas(this.layoutCorrected, this.treeScale, this.path, isShared
|
|
1037
|
+
applyTreeDeltas(this.layoutCorrected, this.treeScale, this.path, isShared &&
|
|
1038
|
+
(lead.relativeTarget && !lead.relativeParent.resumingFrom
|
|
1039
|
+
? lead.relativeParent
|
|
1040
|
+
: true));
|
|
1021
1041
|
/**
|
|
1022
1042
|
* If this layer needs to perform scale correction but doesn't have a target,
|
|
1023
1043
|
* use the layout as the target.
|
|
@@ -1084,8 +1104,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1084
1104
|
scheduleRender(notifyAll = true) {
|
|
1085
1105
|
this.options.visualElement?.scheduleRender();
|
|
1086
1106
|
if (notifyAll) {
|
|
1087
|
-
|
|
1088
|
-
stack && stack.scheduleRender();
|
|
1107
|
+
this.getStack()?.scheduleRender();
|
|
1089
1108
|
}
|
|
1090
1109
|
if (this.resumingFrom && !this.resumingFrom.instance) {
|
|
1091
1110
|
this.resumingFrom = undefined;
|
|
@@ -1107,9 +1126,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1107
1126
|
}
|
|
1108
1127
|
this.attemptToResolveRelativeTarget = !hasOnlyRelativeTargetChanged;
|
|
1109
1128
|
const relativeLayout = createBox();
|
|
1110
|
-
const
|
|
1111
|
-
const layoutSource = this.layout ? this.layout.source : undefined;
|
|
1112
|
-
const isSharedLayoutAnimation = snapshotSource !== layoutSource;
|
|
1129
|
+
const isSharedLayoutAnimation = snapshot?.source !== this.layout?.source;
|
|
1113
1130
|
const stack = this.getStack();
|
|
1114
1131
|
const isOnlyMember = !stack || stack.members.length <= 1;
|
|
1115
1132
|
const shouldCrossfadeOpacity = Boolean(isSharedLayoutAnimation &&
|
|
@@ -1124,19 +1141,11 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1124
1141
|
this.mixTargetDelta = (latest) => {
|
|
1125
1142
|
const progress = latest / 1000;
|
|
1126
1143
|
const point = interpolate?.(progress);
|
|
1144
|
+
mixAxisDeltaLinear(targetDelta.x, delta.x, progress);
|
|
1145
|
+
mixAxisDeltaLinear(targetDelta.y, delta.y, progress);
|
|
1127
1146
|
if (point) {
|
|
1128
1147
|
targetDelta.x.translate = point.x;
|
|
1129
|
-
targetDelta.x.scale = mixNumber(delta.x.scale, 1, progress);
|
|
1130
|
-
targetDelta.x.origin = delta.x.origin;
|
|
1131
|
-
targetDelta.x.originPoint = delta.x.originPoint;
|
|
1132
1148
|
targetDelta.y.translate = point.y;
|
|
1133
|
-
targetDelta.y.scale = mixNumber(delta.y.scale, 1, progress);
|
|
1134
|
-
targetDelta.y.origin = delta.y.origin;
|
|
1135
|
-
targetDelta.y.originPoint = delta.y.originPoint;
|
|
1136
|
-
}
|
|
1137
|
-
else {
|
|
1138
|
-
mixAxisDeltaLinear(targetDelta.x, delta.x, progress);
|
|
1139
|
-
mixAxisDeltaLinear(targetDelta.y, delta.y, progress);
|
|
1140
1149
|
}
|
|
1141
1150
|
this.setTargetDelta(targetDelta);
|
|
1142
1151
|
if (this.relativeTarget &&
|
|
@@ -1162,7 +1171,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1162
1171
|
this.animationValues = mixedValues;
|
|
1163
1172
|
mixValues(mixedValues, snapshotLatestValues, this.latestValues, progress, shouldCrossfadeOpacity, isOnlyMember);
|
|
1164
1173
|
}
|
|
1165
|
-
if (point
|
|
1174
|
+
if (point?.rotate !== undefined) {
|
|
1166
1175
|
// Dedicated `pathRotation` channel, not `rotate`, so an
|
|
1167
1176
|
// animating `rotate` is composed with, never clobbered.
|
|
1168
1177
|
if (!this.animationValues)
|
|
@@ -1227,7 +1236,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1227
1236
|
}
|
|
1228
1237
|
finishAnimation() {
|
|
1229
1238
|
if (this.currentAnimation) {
|
|
1230
|
-
this.mixTargetDelta
|
|
1239
|
+
this.mixTargetDelta?.(animationTarget);
|
|
1231
1240
|
this.currentAnimation.stop();
|
|
1232
1241
|
}
|
|
1233
1242
|
this.completeAnimation();
|
|
@@ -1247,13 +1256,11 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1247
1256
|
this.layout &&
|
|
1248
1257
|
layout &&
|
|
1249
1258
|
shouldAnimatePositionOnly(this.options.animationType, this.layout.layoutBox, layout.layoutBox)) {
|
|
1259
|
+
const { layoutBox } = this.layout;
|
|
1260
|
+
const leadTarget = target;
|
|
1250
1261
|
target = this.target || createBox();
|
|
1251
|
-
|
|
1252
|
-
target.
|
|
1253
|
-
target.x.max = target.x.min + xLength;
|
|
1254
|
-
const yLength = calcLength(this.layout.layoutBox.y);
|
|
1255
|
-
target.y.min = lead.target.y.min;
|
|
1256
|
-
target.y.max = target.y.min + yLength;
|
|
1262
|
+
alignAxis(target.x, leadTarget.x, layoutBox.x);
|
|
1263
|
+
alignAxis(target.y, leadTarget.y, layoutBox.y);
|
|
1257
1264
|
}
|
|
1258
1265
|
copyBoxInto(targetWithTransforms, target);
|
|
1259
1266
|
/**
|
|
@@ -1278,8 +1285,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1278
1285
|
stack.add(node);
|
|
1279
1286
|
const config = node.options.initialPromotionConfig;
|
|
1280
1287
|
node.promote({
|
|
1281
|
-
transition: config
|
|
1282
|
-
preserveFollowOpacity: config
|
|
1288
|
+
transition: config?.transition,
|
|
1289
|
+
preserveFollowOpacity: config?.shouldPreserveFollowOpacity
|
|
1283
1290
|
? config.shouldPreserveFollowOpacity(node)
|
|
1284
1291
|
: undefined,
|
|
1285
1292
|
});
|
|
@@ -1302,9 +1309,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1302
1309
|
return this.root.sharedNodes.get(layoutId);
|
|
1303
1310
|
}
|
|
1304
1311
|
promote({ needsReset, transition, preserveFollowOpacity, } = {}) {
|
|
1305
|
-
|
|
1306
|
-
if (stack)
|
|
1307
|
-
stack.promote(this, preserveFollowOpacity);
|
|
1312
|
+
this.getStack()?.promote(this, preserveFollowOpacity);
|
|
1308
1313
|
if (needsReset) {
|
|
1309
1314
|
this.projectionDelta = undefined;
|
|
1310
1315
|
this.needsReset = true;
|
|
@@ -1313,45 +1318,27 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1313
1318
|
this.setOptions({ transition });
|
|
1314
1319
|
}
|
|
1315
1320
|
relegate() {
|
|
1316
|
-
|
|
1317
|
-
if (stack) {
|
|
1318
|
-
return stack.relegate(this);
|
|
1319
|
-
}
|
|
1320
|
-
else {
|
|
1321
|
-
return false;
|
|
1322
|
-
}
|
|
1321
|
+
return this.getStack()?.relegate(this) || false;
|
|
1323
1322
|
}
|
|
1324
1323
|
resetSkewAndRotation() {
|
|
1325
1324
|
const { visualElement } = this.options;
|
|
1326
1325
|
if (!visualElement)
|
|
1327
1326
|
return;
|
|
1328
|
-
// If there's no detected skew or rotation values, we can early return without a forced render.
|
|
1329
|
-
let hasDistortingTransform = false;
|
|
1330
1327
|
/**
|
|
1331
1328
|
* An unrolled check for rotation values. Most elements don't have any rotation and
|
|
1332
|
-
* skipping the
|
|
1329
|
+
* skipping the loop and new object creation is 50% faster.
|
|
1330
|
+
* If there's no distorting values, we don't need to do any more.
|
|
1333
1331
|
*/
|
|
1334
1332
|
const { latestValues } = visualElement;
|
|
1335
|
-
if (latestValues
|
|
1336
|
-
latestValues.rotate ||
|
|
1337
|
-
latestValues.rotateX ||
|
|
1338
|
-
latestValues.rotateY ||
|
|
1339
|
-
latestValues.rotateZ ||
|
|
1340
|
-
latestValues.skewX ||
|
|
1341
|
-
latestValues.skewY) {
|
|
1342
|
-
hasDistortingTransform = true;
|
|
1343
|
-
}
|
|
1344
|
-
// If there's no distorting values, we don't need to do any more.
|
|
1345
|
-
if (!hasDistortingTransform)
|
|
1333
|
+
if (!hasDistortingTransform(latestValues))
|
|
1346
1334
|
return;
|
|
1347
1335
|
const resetValues = {};
|
|
1348
|
-
if (latestValues.z) {
|
|
1349
|
-
resetDistortingTransform("z", visualElement, resetValues, this.animationValues);
|
|
1350
|
-
}
|
|
1351
1336
|
// Check the skew and rotate value of all axes and reset to 0
|
|
1352
|
-
for (let i = 0; i <
|
|
1353
|
-
resetDistortingTransform(
|
|
1354
|
-
|
|
1337
|
+
for (let i = 0; i < distortingTransforms.length; i++) {
|
|
1338
|
+
resetDistortingTransform(distortingTransforms[i], visualElement, resetValues, this.animationValues);
|
|
1339
|
+
}
|
|
1340
|
+
for (let i = 0; i < angleTransforms.length; i++) {
|
|
1341
|
+
resetDistortingTransform(angleTransforms[i], visualElement, resetValues, this.animationValues);
|
|
1355
1342
|
}
|
|
1356
1343
|
// Force a render of this element to apply the transform with all skews and rotations
|
|
1357
1344
|
// set to 0.
|
|
@@ -1371,7 +1358,13 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1371
1358
|
styleProp) {
|
|
1372
1359
|
if (!this.instance || this.isSVG)
|
|
1373
1360
|
return;
|
|
1374
|
-
|
|
1361
|
+
const lead = this.getLead();
|
|
1362
|
+
/**
|
|
1363
|
+
* Without crossfade, a new lead hides the previous one, as it's
|
|
1364
|
+
* usually unmounting. One that gave its layoutId away keeps
|
|
1365
|
+
* rendering, so only hide nodes that follow another.
|
|
1366
|
+
*/
|
|
1367
|
+
if (!this.isVisible && lead !== this) {
|
|
1375
1368
|
targetStyle.visibility = "hidden";
|
|
1376
1369
|
return;
|
|
1377
1370
|
}
|
|
@@ -1387,9 +1380,10 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1387
1380
|
: "none";
|
|
1388
1381
|
return;
|
|
1389
1382
|
}
|
|
1390
|
-
const lead = this.getLead();
|
|
1391
1383
|
if (!this.projectionDelta || !this.layout || !lead.target) {
|
|
1392
|
-
if (this.options.layoutId) {
|
|
1384
|
+
if (this.options.layoutId || this.needsShow) {
|
|
1385
|
+
this.needsShow = false;
|
|
1386
|
+
targetStyle.visibility = "";
|
|
1393
1387
|
targetStyle.opacity =
|
|
1394
1388
|
this.latestValues.opacity !== undefined
|
|
1395
1389
|
? this.latestValues.opacity
|
|
@@ -1523,52 +1517,49 @@ function notifyLayoutUpdate(node) {
|
|
|
1523
1517
|
const isShared = snapshot.source !== node.layout.source;
|
|
1524
1518
|
// TODO Maybe we want to also resize the layout snapshot so we don't trigger
|
|
1525
1519
|
// animations for instance if layout="size" and an element has only changed position
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
node.relativeTarget[axis].min + length;
|
|
1556
|
-
}
|
|
1557
|
-
});
|
|
1558
|
-
}
|
|
1520
|
+
const resizeSnapshot = (box, to) => {
|
|
1521
|
+
if (animationType === "size") {
|
|
1522
|
+
eachAxis((axis) => {
|
|
1523
|
+
const length = calcLength(box[axis]);
|
|
1524
|
+
box[axis].min = to[axis].min;
|
|
1525
|
+
box[axis].max = box[axis].min + length;
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
else if (animationType === "x" || animationType === "y") {
|
|
1529
|
+
const snapAxis = animationType === "x" ? "y" : "x";
|
|
1530
|
+
copyAxisInto(box[snapAxis], to[snapAxis]);
|
|
1531
|
+
}
|
|
1532
|
+
else if (shouldAnimatePositionOnly(animationType, snapshot.layoutBox, layout)) {
|
|
1533
|
+
eachAxis((axis) => {
|
|
1534
|
+
const length = calcLength(to[axis]);
|
|
1535
|
+
box[axis].max = box[axis].min + length;
|
|
1536
|
+
/**
|
|
1537
|
+
* Ensure relative target gets resized and rerendererd
|
|
1538
|
+
*/
|
|
1539
|
+
if (node.relativeTarget && !node.currentAnimation) {
|
|
1540
|
+
node.isProjectionDirty = true;
|
|
1541
|
+
node.relativeTarget[axis].max =
|
|
1542
|
+
node.relativeTarget[axis].min + length;
|
|
1543
|
+
}
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
};
|
|
1547
|
+
const snapshotBox = isShared ? snapshot.measuredBox : snapshot.layoutBox;
|
|
1548
|
+
resizeSnapshot(snapshotBox, layout);
|
|
1559
1549
|
const layoutDelta = createDelta();
|
|
1560
1550
|
calcBoxDelta(layoutDelta, layout, snapshot.layoutBox);
|
|
1561
1551
|
const visualDelta = createDelta();
|
|
1562
|
-
|
|
1563
|
-
calcBoxDelta(visualDelta, node.applyTransform(measuredLayout, true), snapshot.measuredBox);
|
|
1564
|
-
}
|
|
1565
|
-
else {
|
|
1566
|
-
calcBoxDelta(visualDelta, layout, snapshot.layoutBox);
|
|
1567
|
-
}
|
|
1552
|
+
calcBoxDelta(visualDelta, isShared ? node.applyTransform(measuredLayout, true) : layout, snapshotBox);
|
|
1568
1553
|
const hasLayoutChanged = !isDeltaZero(layoutDelta);
|
|
1569
1554
|
let hasRelativeLayoutChanged = false;
|
|
1570
|
-
|
|
1571
|
-
|
|
1555
|
+
const relativeParent = node.getClosestProjectingParent();
|
|
1556
|
+
/**
|
|
1557
|
+
* A snapshot resumed from another element is only relative to this
|
|
1558
|
+
* node's relativeParent if it's a layoutRoot that contains both.
|
|
1559
|
+
*/
|
|
1560
|
+
if (!node.resumeFrom ||
|
|
1561
|
+
(relativeParent?.options.layoutRoot &&
|
|
1562
|
+
node.resumeFrom.path.includes(relativeParent))) {
|
|
1572
1563
|
/**
|
|
1573
1564
|
* If the relativeParent is itself resuming from a different element then
|
|
1574
1565
|
* the relative snapshot is not relavent
|
|
@@ -1577,10 +1568,22 @@ function notifyLayoutUpdate(node) {
|
|
|
1577
1568
|
const { snapshot: parentSnapshot, layout: parentLayout } = relativeParent;
|
|
1578
1569
|
if (parentSnapshot && parentLayout) {
|
|
1579
1570
|
const anchor = node.options.layoutAnchor || undefined;
|
|
1571
|
+
/**
|
|
1572
|
+
* A shared snapshot includes the transforms of the old
|
|
1573
|
+
* element's ancestors below the layoutRoot, as they
|
|
1574
|
+
* aren't shared with the new element.
|
|
1575
|
+
*/
|
|
1580
1576
|
const relativeSnapshot = createBox();
|
|
1581
|
-
calcRelativePosition(relativeSnapshot,
|
|
1577
|
+
calcRelativePosition(relativeSnapshot, isShared
|
|
1578
|
+
? node.resumeFrom.applyTransform(snapshot.layoutBox, true, undefined, true, relativeParent.depth + 1)
|
|
1579
|
+
: snapshot.layoutBox, parentSnapshot.layoutBox, anchor);
|
|
1582
1580
|
const relativeLayout = createBox();
|
|
1583
1581
|
calcRelativePosition(relativeLayout, layout, parentLayout.layoutBox, anchor);
|
|
1582
|
+
/**
|
|
1583
|
+
* A shared snapshot is resized in page space, above, so
|
|
1584
|
+
* resize it relative to the layoutRoot too.
|
|
1585
|
+
*/
|
|
1586
|
+
isShared && resizeSnapshot(relativeSnapshot, relativeLayout);
|
|
1584
1587
|
if (!boxEqualsRounded(relativeSnapshot, relativeLayout)) {
|
|
1585
1588
|
hasRelativeLayoutChanged = true;
|
|
1586
1589
|
}
|
|
@@ -1602,8 +1605,7 @@ function notifyLayoutUpdate(node) {
|
|
|
1602
1605
|
});
|
|
1603
1606
|
}
|
|
1604
1607
|
else if (node.isLead()) {
|
|
1605
|
-
|
|
1606
|
-
onExitComplete && onExitComplete();
|
|
1608
|
+
node.options.onExitComplete?.();
|
|
1607
1609
|
}
|
|
1608
1610
|
/**
|
|
1609
1611
|
* Clearing transition
|
|
@@ -1709,7 +1711,7 @@ function syncRelativeLayout(node) {
|
|
|
1709
1711
|
}
|
|
1710
1712
|
function resetTransformStyle(node) {
|
|
1711
1713
|
const { visualElement } = node.options;
|
|
1712
|
-
if (visualElement
|
|
1714
|
+
if (visualElement?.getProps().onBeforeLayoutMeasure) {
|
|
1713
1715
|
visualElement.notify("BeforeLayoutMeasure");
|
|
1714
1716
|
}
|
|
1715
1717
|
node.resetTransform();
|
|
@@ -1743,7 +1745,7 @@ function mixBox(output, from, to, p) {
|
|
|
1743
1745
|
mixAxis(output.y, from.y, to.y, p);
|
|
1744
1746
|
}
|
|
1745
1747
|
function hasOpacityCrossfade(node) {
|
|
1746
|
-
return
|
|
1748
|
+
return node.animationValues?.opacityExit !== undefined;
|
|
1747
1749
|
}
|
|
1748
1750
|
const defaultLayoutTransition = {
|
|
1749
1751
|
duration: 0.45,
|
|
@@ -1769,6 +1771,13 @@ function roundBox(box) {
|
|
|
1769
1771
|
roundAxis(box.x);
|
|
1770
1772
|
roundAxis(box.y);
|
|
1771
1773
|
}
|
|
1774
|
+
/**
|
|
1775
|
+
* Align an axis to the start of another, keeping the length of a layout axis.
|
|
1776
|
+
* The length is read first, as output can be the layout axis itself.
|
|
1777
|
+
*/
|
|
1778
|
+
function alignAxis(output, from, layout) {
|
|
1779
|
+
output.max = calcLength(layout) + (output.min = from.min);
|
|
1780
|
+
}
|
|
1772
1781
|
function shouldAnimatePositionOnly(animationType, snapshot, layout) {
|
|
1773
1782
|
return (animationType === "position" ||
|
|
1774
1783
|
(animationType === "preserve-aspect" &&
|