motion-dom 12.36.0 → 12.38.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 +179 -83
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/AsyncMotionValueAnimation.mjs +15 -6
- package/dist/es/animation/AsyncMotionValueAnimation.mjs.map +1 -1
- package/dist/es/animation/JSAnimation.mjs +16 -3
- package/dist/es/animation/JSAnimation.mjs.map +1 -1
- package/dist/es/animation/interfaces/motion-value.mjs +1 -1
- package/dist/es/animation/interfaces/motion-value.mjs.map +1 -1
- package/dist/es/animation/interfaces/visual-element-target.mjs +4 -1
- package/dist/es/animation/interfaces/visual-element-target.mjs.map +1 -1
- package/dist/es/animation/utils/active-animations.mjs +5 -2
- package/dist/es/animation/utils/active-animations.mjs.map +1 -1
- package/dist/es/animation/utils/is-transition-defined.mjs +18 -2
- package/dist/es/animation/utils/is-transition-defined.mjs.map +1 -1
- package/dist/es/animation/waapi/supports/waapi.mjs +21 -12
- package/dist/es/animation/waapi/supports/waapi.mjs.map +1 -1
- package/dist/es/animation/waapi/utils/is-browser-color.mjs +13 -0
- package/dist/es/animation/waapi/utils/is-browser-color.mjs.map +1 -0
- package/dist/es/index.mjs +1 -1
- package/dist/es/projection/animation/mix-values.mjs +8 -3
- package/dist/es/projection/animation/mix-values.mjs.map +1 -1
- package/dist/es/projection/geometry/delta-apply.mjs +4 -6
- package/dist/es/projection/geometry/delta-apply.mjs.map +1 -1
- package/dist/es/projection/geometry/delta-calc.mjs +16 -10
- package/dist/es/projection/geometry/delta-calc.mjs.map +1 -1
- package/dist/es/projection/node/create-projection-node.mjs +49 -16
- package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
- package/dist/es/value/follow-value.mjs +3 -0
- package/dist/es/value/follow-value.mjs.map +1 -1
- package/dist/index.d.ts +30 -11
- package/dist/motion-dom.dev.js +179 -83
- package/dist/motion-dom.js +1 -1
- package/package.json +2 -2
- package/dist/es/animation/utils/get-final-keyframe.mjs +0 -13
- package/dist/es/animation/utils/get-final-keyframe.mjs.map +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1324,9 +1324,9 @@ function keyframes({ duration = 300, keyframes: keyframeValues, times, ease = "e
|
|
|
1324
1324
|
};
|
|
1325
1325
|
}
|
|
1326
1326
|
|
|
1327
|
-
const isNotNull
|
|
1328
|
-
function getFinalKeyframe
|
|
1329
|
-
const resolvedKeyframes = keyframes.filter(isNotNull
|
|
1327
|
+
const isNotNull = (value) => value !== null;
|
|
1328
|
+
function getFinalKeyframe(keyframes, { repeat, repeatType = "loop" }, finalKeyframe, speed = 1) {
|
|
1329
|
+
const resolvedKeyframes = keyframes.filter(isNotNull);
|
|
1330
1330
|
const useFirstKeyframe = speed < 0 || (repeat && repeatType !== "loop" && repeat % 2 === 1);
|
|
1331
1331
|
const index = useFirstKeyframe ? 0 : resolvedKeyframes.length - 1;
|
|
1332
1332
|
return !index || finalKeyframe === undefined
|
|
@@ -1391,6 +1391,14 @@ class JSAnimation extends WithPromise {
|
|
|
1391
1391
|
* Playback speed as a factor. 0 would be stopped, -1 reverse and 2 double speed.
|
|
1392
1392
|
*/
|
|
1393
1393
|
this.playbackSpeed = 1;
|
|
1394
|
+
/**
|
|
1395
|
+
* Reusable state object for the delay phase to avoid
|
|
1396
|
+
* allocating a new object every frame.
|
|
1397
|
+
*/
|
|
1398
|
+
this.delayState = {
|
|
1399
|
+
done: false,
|
|
1400
|
+
value: undefined,
|
|
1401
|
+
};
|
|
1394
1402
|
/**
|
|
1395
1403
|
* This method is bound to the instance to fix a pattern where
|
|
1396
1404
|
* animation.stop is returned as a reference from a useEffect.
|
|
@@ -1553,9 +1561,14 @@ class JSAnimation extends WithPromise {
|
|
|
1553
1561
|
* This prevents delay: x, duration: 0 animations from finishing
|
|
1554
1562
|
* instantly.
|
|
1555
1563
|
*/
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1564
|
+
let state;
|
|
1565
|
+
if (isInDelayPhase) {
|
|
1566
|
+
this.delayState.value = keyframes[0];
|
|
1567
|
+
state = this.delayState;
|
|
1568
|
+
}
|
|
1569
|
+
else {
|
|
1570
|
+
state = frameGenerator.next(elapsed);
|
|
1571
|
+
}
|
|
1559
1572
|
if (mixKeyframes && !isInDelayPhase) {
|
|
1560
1573
|
state.value = mixKeyframes(state.value);
|
|
1561
1574
|
}
|
|
@@ -1570,7 +1583,7 @@ class JSAnimation extends WithPromise {
|
|
|
1570
1583
|
(this.state === "finished" || (this.state === "running" && done));
|
|
1571
1584
|
// TODO: The exception for inertia could be cleaner here
|
|
1572
1585
|
if (isAnimationFinished && type !== inertia) {
|
|
1573
|
-
state.value = getFinalKeyframe
|
|
1586
|
+
state.value = getFinalKeyframe(keyframes, this.options, finalKeyframe, this.speed);
|
|
1574
1587
|
}
|
|
1575
1588
|
if (onUpdate) {
|
|
1576
1589
|
onUpdate(state.value);
|
|
@@ -2178,7 +2191,7 @@ class NativeAnimation extends WithPromise {
|
|
|
2178
2191
|
this.animation.onfinish = () => {
|
|
2179
2192
|
this.finishedTime = this.time;
|
|
2180
2193
|
if (!pseudoElement) {
|
|
2181
|
-
const keyframe = getFinalKeyframe
|
|
2194
|
+
const keyframe = getFinalKeyframe(keyframes, this.options, finalKeyframe, this.speed);
|
|
2182
2195
|
if (this.updateMotionValue) {
|
|
2183
2196
|
this.updateMotionValue(keyframe);
|
|
2184
2197
|
}
|
|
@@ -2484,17 +2497,42 @@ function makeAnimationInstant(options) {
|
|
|
2484
2497
|
/**
|
|
2485
2498
|
* A list of values that can be hardware-accelerated.
|
|
2486
2499
|
*/
|
|
2487
|
-
const acceleratedValues
|
|
2500
|
+
const acceleratedValues = new Set([
|
|
2488
2501
|
"opacity",
|
|
2489
2502
|
"clipPath",
|
|
2490
2503
|
"filter",
|
|
2491
2504
|
"transform",
|
|
2492
|
-
// TODO:
|
|
2505
|
+
// TODO: Can be accelerated but currently disabled until https://issues.chromium.org/issues/41491098 is resolved
|
|
2506
|
+
// or until we implement support for linear() easing.
|
|
2493
2507
|
// "background-color"
|
|
2494
2508
|
]);
|
|
2509
|
+
|
|
2510
|
+
const browserColorFunctions = /^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;
|
|
2511
|
+
function hasBrowserOnlyColors(keyframes) {
|
|
2512
|
+
for (let i = 0; i < keyframes.length; i++) {
|
|
2513
|
+
if (typeof keyframes[i] === "string" &&
|
|
2514
|
+
browserColorFunctions.test(keyframes[i])) {
|
|
2515
|
+
return true;
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
return false;
|
|
2519
|
+
}
|
|
2520
|
+
|
|
2521
|
+
const colorProperties = new Set([
|
|
2522
|
+
"color",
|
|
2523
|
+
"backgroundColor",
|
|
2524
|
+
"outlineColor",
|
|
2525
|
+
"fill",
|
|
2526
|
+
"stroke",
|
|
2527
|
+
"borderColor",
|
|
2528
|
+
"borderTopColor",
|
|
2529
|
+
"borderRightColor",
|
|
2530
|
+
"borderBottomColor",
|
|
2531
|
+
"borderLeftColor",
|
|
2532
|
+
]);
|
|
2495
2533
|
const supportsWaapi = /*@__PURE__*/ motionUtils.memo(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
|
|
2496
2534
|
function supportsBrowserAnimation(options) {
|
|
2497
|
-
const { motionValue, name, repeatDelay, repeatType, damping, type } = options;
|
|
2535
|
+
const { motionValue, name, repeatDelay, repeatType, damping, type, keyframes, } = options;
|
|
2498
2536
|
const subject = motionValue?.owner?.current;
|
|
2499
2537
|
/**
|
|
2500
2538
|
* We use this check instead of isHTMLElement() because we explicitly
|
|
@@ -2508,7 +2546,13 @@ function supportsBrowserAnimation(options) {
|
|
|
2508
2546
|
const { onUpdate, transformTemplate } = motionValue.owner.getProps();
|
|
2509
2547
|
return (supportsWaapi() &&
|
|
2510
2548
|
name &&
|
|
2511
|
-
|
|
2549
|
+
/**
|
|
2550
|
+
* Force WAAPI for color properties with browser-only color formats
|
|
2551
|
+
* (oklch, oklab, lab, lch, etc.) that the JS animation path can't parse.
|
|
2552
|
+
*/
|
|
2553
|
+
(acceleratedValues.has(name) ||
|
|
2554
|
+
(colorProperties.has(name) &&
|
|
2555
|
+
hasBrowserOnlyColors(keyframes))) &&
|
|
2512
2556
|
(name !== "transform" || !transformTemplate) &&
|
|
2513
2557
|
/**
|
|
2514
2558
|
* If we're outputting values to onUpdate then we can't use WAAPI as there's
|
|
@@ -2572,7 +2616,7 @@ class AsyncMotionValueAnimation extends WithPromise {
|
|
|
2572
2616
|
if (!canAnimate(keyframes, name, type, velocity)) {
|
|
2573
2617
|
canAnimateValue = false;
|
|
2574
2618
|
if (motionUtils.MotionGlobalConfig.instantAnimations || !delay) {
|
|
2575
|
-
onUpdate?.(getFinalKeyframe
|
|
2619
|
+
onUpdate?.(getFinalKeyframe(keyframes, options, finalKeyframe));
|
|
2576
2620
|
}
|
|
2577
2621
|
keyframes[0] = keyframes[keyframes.length - 1];
|
|
2578
2622
|
makeAnimationInstant(options);
|
|
@@ -2615,12 +2659,21 @@ class AsyncMotionValueAnimation extends WithPromise {
|
|
|
2615
2659
|
!isHandoff &&
|
|
2616
2660
|
supportsBrowserAnimation(resolvedOptions);
|
|
2617
2661
|
const element = resolvedOptions.motionValue?.owner?.current;
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2662
|
+
let animation;
|
|
2663
|
+
if (useWaapi) {
|
|
2664
|
+
try {
|
|
2665
|
+
animation = new NativeAnimationExtended({
|
|
2666
|
+
...resolvedOptions,
|
|
2667
|
+
element,
|
|
2668
|
+
});
|
|
2669
|
+
}
|
|
2670
|
+
catch {
|
|
2671
|
+
animation = new JSAnimation(resolvedOptions);
|
|
2672
|
+
}
|
|
2673
|
+
}
|
|
2674
|
+
else {
|
|
2675
|
+
animation = new JSAnimation(resolvedOptions);
|
|
2676
|
+
}
|
|
2624
2677
|
animation.finished.then(() => {
|
|
2625
2678
|
this.notifyFinished();
|
|
2626
2679
|
}).catch(motionUtils.noop);
|
|
@@ -2798,8 +2851,11 @@ class NativeAnimationWrapper extends NativeAnimation {
|
|
|
2798
2851
|
const animationMaps = new WeakMap();
|
|
2799
2852
|
const animationMapKey = (name, pseudoElement = "") => `${name}:${pseudoElement}`;
|
|
2800
2853
|
function getAnimationMap(element) {
|
|
2801
|
-
|
|
2802
|
-
|
|
2854
|
+
let map = animationMaps.get(element);
|
|
2855
|
+
if (!map) {
|
|
2856
|
+
map = new Map();
|
|
2857
|
+
animationMaps.set(element, map);
|
|
2858
|
+
}
|
|
2803
2859
|
return map;
|
|
2804
2860
|
}
|
|
2805
2861
|
|
|
@@ -2891,17 +2947,6 @@ const getDefaultTransition = (valueKey, { keyframes }) => {
|
|
|
2891
2947
|
return ease;
|
|
2892
2948
|
};
|
|
2893
2949
|
|
|
2894
|
-
const isNotNull = (value) => value !== null;
|
|
2895
|
-
function getFinalKeyframe(keyframes, { repeat, repeatType = "loop" }, finalKeyframe) {
|
|
2896
|
-
const resolvedKeyframes = keyframes.filter(isNotNull);
|
|
2897
|
-
const index = repeat && repeatType !== "loop" && repeat % 2 === 1
|
|
2898
|
-
? 0
|
|
2899
|
-
: resolvedKeyframes.length - 1;
|
|
2900
|
-
return !index || finalKeyframe === undefined
|
|
2901
|
-
? resolvedKeyframes[index]
|
|
2902
|
-
: finalKeyframe;
|
|
2903
|
-
}
|
|
2904
|
-
|
|
2905
2950
|
/**
|
|
2906
2951
|
* If `transition` has `inherit: true`, shallow-merge it with
|
|
2907
2952
|
* `parentTransition` (child keys win) and strip the `inherit` key.
|
|
@@ -2925,13 +2970,29 @@ function getValueTransition(transition, key) {
|
|
|
2925
2970
|
return valueTransition;
|
|
2926
2971
|
}
|
|
2927
2972
|
|
|
2973
|
+
const orchestrationKeys = new Set([
|
|
2974
|
+
"when",
|
|
2975
|
+
"delay",
|
|
2976
|
+
"delayChildren",
|
|
2977
|
+
"staggerChildren",
|
|
2978
|
+
"staggerDirection",
|
|
2979
|
+
"repeat",
|
|
2980
|
+
"repeatType",
|
|
2981
|
+
"repeatDelay",
|
|
2982
|
+
"from",
|
|
2983
|
+
"elapsed",
|
|
2984
|
+
]);
|
|
2928
2985
|
/**
|
|
2929
2986
|
* Decide whether a transition is defined on a given Transition.
|
|
2930
2987
|
* This filters out orchestration options and returns true
|
|
2931
2988
|
* if any options are left.
|
|
2932
2989
|
*/
|
|
2933
|
-
function isTransitionDefined(
|
|
2934
|
-
|
|
2990
|
+
function isTransitionDefined(transition) {
|
|
2991
|
+
for (const key in transition) {
|
|
2992
|
+
if (!orchestrationKeys.has(key))
|
|
2993
|
+
return true;
|
|
2994
|
+
}
|
|
2995
|
+
return false;
|
|
2935
2996
|
}
|
|
2936
2997
|
|
|
2937
2998
|
const animateMotionValue = (name, value, target, transition = {}, element, isHandoff) => (onComplete) => {
|
|
@@ -3495,13 +3556,16 @@ function animateTarget(visualElement, targetAndTransition, { delay = 0, transiti
|
|
|
3495
3556
|
};
|
|
3496
3557
|
/**
|
|
3497
3558
|
* If the value is already at the defined target, skip the animation.
|
|
3559
|
+
* We still re-assert the value via frame.update to take precedence
|
|
3560
|
+
* over any stale transitionEnd callbacks from previous animations.
|
|
3498
3561
|
*/
|
|
3499
3562
|
const currentValue = value.get();
|
|
3500
3563
|
if (currentValue !== undefined &&
|
|
3501
|
-
!value.isAnimating &&
|
|
3564
|
+
!value.isAnimating() &&
|
|
3502
3565
|
!Array.isArray(valueTarget) &&
|
|
3503
3566
|
valueTarget === currentValue &&
|
|
3504
3567
|
!valueTransition.velocity) {
|
|
3568
|
+
frame.update(() => value.set(valueTarget));
|
|
3505
3569
|
continue;
|
|
3506
3570
|
}
|
|
3507
3571
|
/**
|
|
@@ -4063,19 +4127,6 @@ const supportsPartialKeyframes = /*@__PURE__*/ motionUtils.memo(() => {
|
|
|
4063
4127
|
return true;
|
|
4064
4128
|
});
|
|
4065
4129
|
|
|
4066
|
-
/**
|
|
4067
|
-
* A list of values that can be hardware-accelerated.
|
|
4068
|
-
*/
|
|
4069
|
-
const acceleratedValues = new Set([
|
|
4070
|
-
"opacity",
|
|
4071
|
-
"clipPath",
|
|
4072
|
-
"filter",
|
|
4073
|
-
"transform",
|
|
4074
|
-
// TODO: Can be accelerated but currently disabled until https://issues.chromium.org/issues/41491098 is resolved
|
|
4075
|
-
// or until we implement support for linear() easing.
|
|
4076
|
-
// "background-color"
|
|
4077
|
-
]);
|
|
4078
|
-
|
|
4079
4130
|
function resolveElements(elementOrSelector, scope, selectorCache) {
|
|
4080
4131
|
if (elementOrSelector == null) {
|
|
4081
4132
|
return [];
|
|
@@ -4961,6 +5012,7 @@ function attachFollow(value, source, options = {}) {
|
|
|
4961
5012
|
activeAnimation.stop();
|
|
4962
5013
|
activeAnimation = null;
|
|
4963
5014
|
}
|
|
5015
|
+
value.animation = undefined;
|
|
4964
5016
|
};
|
|
4965
5017
|
const startAnimation = () => {
|
|
4966
5018
|
const currentValue = asNumber$1(value.get());
|
|
@@ -4992,8 +5044,10 @@ function attachFollow(value, source, options = {}) {
|
|
|
4992
5044
|
// multiple calls within the same frame (e.g. rapid mouse events)
|
|
4993
5045
|
const scheduleAnimation = () => {
|
|
4994
5046
|
startAnimation();
|
|
5047
|
+
value.animation = activeAnimation ?? undefined;
|
|
4995
5048
|
value["events"].animationStart?.notify();
|
|
4996
5049
|
activeAnimation?.then(() => {
|
|
5050
|
+
value.animation = undefined;
|
|
4997
5051
|
value["events"].animationComplete?.notify();
|
|
4998
5052
|
});
|
|
4999
5053
|
};
|
|
@@ -6292,10 +6346,8 @@ function applyTreeDeltas(box, treeScale, treePath, isSharedTransition = false) {
|
|
|
6292
6346
|
node.options.layoutScroll &&
|
|
6293
6347
|
node.scroll &&
|
|
6294
6348
|
node !== node.root) {
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
y: -node.scroll.offset.y,
|
|
6298
|
-
});
|
|
6349
|
+
translateAxis(box.x, -node.scroll.offset.x);
|
|
6350
|
+
translateAxis(box.y, -node.scroll.offset.y);
|
|
6299
6351
|
}
|
|
6300
6352
|
if (delta) {
|
|
6301
6353
|
// Incoporate each ancestor's scale into a cumulative treeScale for this component
|
|
@@ -6322,8 +6374,8 @@ function applyTreeDeltas(box, treeScale, treePath, isSharedTransition = false) {
|
|
|
6322
6374
|
}
|
|
6323
6375
|
}
|
|
6324
6376
|
function translateAxis(axis, distance) {
|
|
6325
|
-
axis.min
|
|
6326
|
-
axis.max
|
|
6377
|
+
axis.min += distance;
|
|
6378
|
+
axis.max += distance;
|
|
6327
6379
|
}
|
|
6328
6380
|
/**
|
|
6329
6381
|
* Apply a transform to an axis from the latest resolved motion values.
|
|
@@ -7344,21 +7396,27 @@ function calcBoxDelta(delta, source, target, origin) {
|
|
|
7344
7396
|
calcAxisDelta(delta.x, source.x, target.x, origin ? origin.originX : undefined);
|
|
7345
7397
|
calcAxisDelta(delta.y, source.y, target.y, origin ? origin.originY : undefined);
|
|
7346
7398
|
}
|
|
7347
|
-
function calcRelativeAxis(target, relative, parent) {
|
|
7348
|
-
|
|
7399
|
+
function calcRelativeAxis(target, relative, parent, anchor = 0) {
|
|
7400
|
+
const anchorPoint = anchor
|
|
7401
|
+
? mixNumber$1(parent.min, parent.max, anchor)
|
|
7402
|
+
: parent.min;
|
|
7403
|
+
target.min = anchorPoint + relative.min;
|
|
7349
7404
|
target.max = target.min + calcLength(relative);
|
|
7350
7405
|
}
|
|
7351
|
-
function calcRelativeBox(target, relative, parent) {
|
|
7352
|
-
calcRelativeAxis(target.x, relative.x, parent.x);
|
|
7353
|
-
calcRelativeAxis(target.y, relative.y, parent.y);
|
|
7406
|
+
function calcRelativeBox(target, relative, parent, anchor) {
|
|
7407
|
+
calcRelativeAxis(target.x, relative.x, parent.x, anchor?.x);
|
|
7408
|
+
calcRelativeAxis(target.y, relative.y, parent.y, anchor?.y);
|
|
7354
7409
|
}
|
|
7355
|
-
function calcRelativeAxisPosition(target, layout, parent) {
|
|
7356
|
-
|
|
7410
|
+
function calcRelativeAxisPosition(target, layout, parent, anchor = 0) {
|
|
7411
|
+
const anchorPoint = anchor
|
|
7412
|
+
? mixNumber$1(parent.min, parent.max, anchor)
|
|
7413
|
+
: parent.min;
|
|
7414
|
+
target.min = layout.min - anchorPoint;
|
|
7357
7415
|
target.max = target.min + calcLength(layout);
|
|
7358
7416
|
}
|
|
7359
|
-
function calcRelativePosition(target, layout, parent) {
|
|
7360
|
-
calcRelativeAxisPosition(target.x, layout.x, parent.x);
|
|
7361
|
-
calcRelativeAxisPosition(target.y, layout.y, parent.y);
|
|
7417
|
+
function calcRelativePosition(target, layout, parent, anchor) {
|
|
7418
|
+
calcRelativeAxisPosition(target.x, layout.x, parent.x, anchor?.x);
|
|
7419
|
+
calcRelativeAxisPosition(target.y, layout.y, parent.y, anchor?.y);
|
|
7362
7420
|
}
|
|
7363
7421
|
|
|
7364
7422
|
/**
|
|
@@ -7490,8 +7548,13 @@ function buildProjectionTransform(delta, treeScale, latestTransform) {
|
|
|
7490
7548
|
return transform || "none";
|
|
7491
7549
|
}
|
|
7492
7550
|
|
|
7493
|
-
const
|
|
7494
|
-
|
|
7551
|
+
const borderLabels = [
|
|
7552
|
+
"borderTopLeftRadius",
|
|
7553
|
+
"borderTopRightRadius",
|
|
7554
|
+
"borderBottomLeftRadius",
|
|
7555
|
+
"borderBottomRightRadius",
|
|
7556
|
+
];
|
|
7557
|
+
const numBorders = borderLabels.length;
|
|
7495
7558
|
const asNumber = (value) => typeof value === "string" ? parseFloat(value) : value;
|
|
7496
7559
|
const isPx = (value) => typeof value === "number" || px.test(value);
|
|
7497
7560
|
function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnlyMember) {
|
|
@@ -7506,7 +7569,7 @@ function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnl
|
|
|
7506
7569
|
* Mix border radius
|
|
7507
7570
|
*/
|
|
7508
7571
|
for (let i = 0; i < numBorders; i++) {
|
|
7509
|
-
const borderLabel =
|
|
7572
|
+
const borderLabel = borderLabels[i];
|
|
7510
7573
|
let followRadius = getRadius(follow, borderLabel);
|
|
7511
7574
|
let leadRadius = getRadius(lead, borderLabel);
|
|
7512
7575
|
if (followRadius === undefined && leadRadius === undefined)
|
|
@@ -8133,8 +8196,18 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
8133
8196
|
// but should still clean up the measurements so that the next
|
|
8134
8197
|
// snapshot could be taken correctly.
|
|
8135
8198
|
if (updateWasBlocked) {
|
|
8199
|
+
const wasBlockedByResize = this.updateBlockedByResize;
|
|
8136
8200
|
this.unblockUpdate();
|
|
8201
|
+
this.updateBlockedByResize = false;
|
|
8137
8202
|
this.clearAllSnapshots();
|
|
8203
|
+
/**
|
|
8204
|
+
* When blocked by resize, still measure layouts so
|
|
8205
|
+
* callbacks like onLayoutMeasure fire (e.g. Reorder).
|
|
8206
|
+
* Skip notifyLayoutUpdate to prevent animations.
|
|
8207
|
+
*/
|
|
8208
|
+
if (wasBlockedByResize) {
|
|
8209
|
+
this.nodes.forEach(forceLayoutMeasure);
|
|
8210
|
+
}
|
|
8138
8211
|
this.nodes.forEach(clearMeasurements);
|
|
8139
8212
|
return;
|
|
8140
8213
|
}
|
|
@@ -8151,6 +8224,11 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
8151
8224
|
}
|
|
8152
8225
|
else {
|
|
8153
8226
|
this.isUpdating = false;
|
|
8227
|
+
/**
|
|
8228
|
+
* Ensure animation-blocked nodes (e.g. during drag)
|
|
8229
|
+
* get measured even when memoized (willUpdate skipped).
|
|
8230
|
+
*/
|
|
8231
|
+
this.nodes.forEach(ensureDraggedNodesSnapshotted);
|
|
8154
8232
|
/**
|
|
8155
8233
|
* Write
|
|
8156
8234
|
*/
|
|
@@ -8249,7 +8327,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
8249
8327
|
const prevLayout = this.layout;
|
|
8250
8328
|
this.layout = this.measure(false);
|
|
8251
8329
|
this.layoutVersion++;
|
|
8252
|
-
this.layoutCorrected
|
|
8330
|
+
if (!this.layoutCorrected)
|
|
8331
|
+
this.layoutCorrected = createBox();
|
|
8253
8332
|
this.isLayoutDirty = false;
|
|
8254
8333
|
this.projectionDelta = undefined;
|
|
8255
8334
|
this.notifyListeners("measure", this.layout.layoutBox);
|
|
@@ -8360,8 +8439,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
8360
8439
|
}
|
|
8361
8440
|
return boxWithoutScroll;
|
|
8362
8441
|
}
|
|
8363
|
-
applyTransform(box, transformOnly = false) {
|
|
8364
|
-
const withTransforms = createBox();
|
|
8442
|
+
applyTransform(box, transformOnly = false, output) {
|
|
8443
|
+
const withTransforms = output || createBox();
|
|
8365
8444
|
copyBoxInto(withTransforms, box);
|
|
8366
8445
|
for (let i = 0; i < this.path.length; i++) {
|
|
8367
8446
|
const node = this.path[i];
|
|
@@ -8369,10 +8448,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
8369
8448
|
node.options.layoutScroll &&
|
|
8370
8449
|
node.scroll &&
|
|
8371
8450
|
node !== node.root) {
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
y: -node.scroll.offset.y,
|
|
8375
|
-
});
|
|
8451
|
+
translateAxis(withTransforms.x, -node.scroll.offset.x);
|
|
8452
|
+
translateAxis(withTransforms.y, -node.scroll.offset.y);
|
|
8376
8453
|
}
|
|
8377
8454
|
if (!hasTransform(node.latestValues))
|
|
8378
8455
|
continue;
|
|
@@ -8480,7 +8557,9 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
8480
8557
|
* even if no animation has started.
|
|
8481
8558
|
*/
|
|
8482
8559
|
if (!this.targetDelta && !this.relativeTarget) {
|
|
8483
|
-
if (
|
|
8560
|
+
if (this.options.layoutAnchor !== false &&
|
|
8561
|
+
relativeParent &&
|
|
8562
|
+
relativeParent.layout) {
|
|
8484
8563
|
this.createRelativeTarget(relativeParent, this.layout.layoutBox, relativeParent.layout.layoutBox);
|
|
8485
8564
|
}
|
|
8486
8565
|
else {
|
|
@@ -8508,15 +8587,14 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
8508
8587
|
this.relativeParent &&
|
|
8509
8588
|
this.relativeParent.target) {
|
|
8510
8589
|
this.forceRelativeParentToResolveTarget();
|
|
8511
|
-
calcRelativeBox(this.target, this.relativeTarget, this.relativeParent.target);
|
|
8590
|
+
calcRelativeBox(this.target, this.relativeTarget, this.relativeParent.target, this.options.layoutAnchor || undefined);
|
|
8512
8591
|
/**
|
|
8513
8592
|
* If we've only got a targetDelta, resolve it into a target
|
|
8514
8593
|
*/
|
|
8515
8594
|
}
|
|
8516
8595
|
else if (this.targetDelta) {
|
|
8517
8596
|
if (Boolean(this.resumingFrom)) {
|
|
8518
|
-
|
|
8519
|
-
this.target = this.applyTransform(this.layout.layoutBox);
|
|
8597
|
+
this.applyTransform(this.layout.layoutBox, false, this.target);
|
|
8520
8598
|
}
|
|
8521
8599
|
else {
|
|
8522
8600
|
copyBoxInto(this.target, this.layout.layoutBox);
|
|
@@ -8534,7 +8612,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
8534
8612
|
*/
|
|
8535
8613
|
if (this.attemptToResolveRelativeTarget) {
|
|
8536
8614
|
this.attemptToResolveRelativeTarget = false;
|
|
8537
|
-
if (
|
|
8615
|
+
if (this.options.layoutAnchor !== false &&
|
|
8616
|
+
relativeParent &&
|
|
8538
8617
|
Boolean(relativeParent.resumingFrom) ===
|
|
8539
8618
|
Boolean(this.resumingFrom) &&
|
|
8540
8619
|
!relativeParent.options.layoutScroll &&
|
|
@@ -8578,7 +8657,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
8578
8657
|
this.forceRelativeParentToResolveTarget();
|
|
8579
8658
|
this.relativeTarget = createBox();
|
|
8580
8659
|
this.relativeTargetOrigin = createBox();
|
|
8581
|
-
calcRelativePosition(this.relativeTargetOrigin, layout, parentLayout);
|
|
8660
|
+
calcRelativePosition(this.relativeTargetOrigin, layout, parentLayout, this.options.layoutAnchor || undefined);
|
|
8582
8661
|
copyBoxInto(this.relativeTarget, this.relativeTargetOrigin);
|
|
8583
8662
|
}
|
|
8584
8663
|
removeRelativeTarget() {
|
|
@@ -8750,7 +8829,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
8750
8829
|
this.layout &&
|
|
8751
8830
|
this.relativeParent &&
|
|
8752
8831
|
this.relativeParent.layout) {
|
|
8753
|
-
calcRelativePosition(relativeLayout, this.layout.layoutBox, this.relativeParent.layout.layoutBox);
|
|
8832
|
+
calcRelativePosition(relativeLayout, this.layout.layoutBox, this.relativeParent.layout.layoutBox, this.options.layoutAnchor || undefined);
|
|
8754
8833
|
mixBox(this.relativeTarget, this.relativeTargetOrigin, relativeLayout, progress);
|
|
8755
8834
|
/**
|
|
8756
8835
|
* If this is an unchanged relative target we can consider the
|
|
@@ -9169,10 +9248,11 @@ function notifyLayoutUpdate(node) {
|
|
|
9169
9248
|
if (relativeParent && !relativeParent.resumeFrom) {
|
|
9170
9249
|
const { snapshot: parentSnapshot, layout: parentLayout } = relativeParent;
|
|
9171
9250
|
if (parentSnapshot && parentLayout) {
|
|
9251
|
+
const anchor = node.options.layoutAnchor || undefined;
|
|
9172
9252
|
const relativeSnapshot = createBox();
|
|
9173
|
-
calcRelativePosition(relativeSnapshot, snapshot.layoutBox, parentSnapshot.layoutBox);
|
|
9253
|
+
calcRelativePosition(relativeSnapshot, snapshot.layoutBox, parentSnapshot.layoutBox, anchor);
|
|
9174
9254
|
const relativeLayout = createBox();
|
|
9175
|
-
calcRelativePosition(relativeLayout, layout, parentLayout.layoutBox);
|
|
9255
|
+
calcRelativePosition(relativeLayout, layout, parentLayout.layoutBox, anchor);
|
|
9176
9256
|
if (!boxEqualsRounded(relativeSnapshot, relativeLayout)) {
|
|
9177
9257
|
hasRelativeLayoutChanged = true;
|
|
9178
9258
|
}
|
|
@@ -9244,9 +9324,25 @@ function clearSnapshot(node) {
|
|
|
9244
9324
|
function clearMeasurements(node) {
|
|
9245
9325
|
node.clearMeasurements();
|
|
9246
9326
|
}
|
|
9327
|
+
function forceLayoutMeasure(node) {
|
|
9328
|
+
node.isLayoutDirty = true;
|
|
9329
|
+
node.updateLayout();
|
|
9330
|
+
}
|
|
9247
9331
|
function clearIsLayoutDirty(node) {
|
|
9248
9332
|
node.isLayoutDirty = false;
|
|
9249
9333
|
}
|
|
9334
|
+
/**
|
|
9335
|
+
* When a node is animation-blocked (e.g. during drag) and its component
|
|
9336
|
+
* didn't re-render (memoized), willUpdate() is never called so there's
|
|
9337
|
+
* no snapshot. Use the previous layout as a snapshot and mark dirty so
|
|
9338
|
+
* resetTransform/updateLayout/notifyLayoutUpdate process it normally.
|
|
9339
|
+
*/
|
|
9340
|
+
function ensureDraggedNodesSnapshotted(node) {
|
|
9341
|
+
if (node.isAnimationBlocked && node.layout && !node.isLayoutDirty) {
|
|
9342
|
+
node.snapshot = node.layout;
|
|
9343
|
+
node.isLayoutDirty = true;
|
|
9344
|
+
}
|
|
9345
|
+
}
|
|
9250
9346
|
function resetTransformStyle(node) {
|
|
9251
9347
|
const { visualElement } = node.options;
|
|
9252
9348
|
if (visualElement && visualElement.getProps().onBeforeLayoutMeasure) {
|