motion-dom 12.35.1 → 12.35.2
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 +177 -76
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/JSAnimation.mjs +17 -0
- package/dist/es/animation/JSAnimation.mjs.map +1 -1
- package/dist/es/animation/NativeAnimationExtended.mjs +6 -1
- package/dist/es/animation/NativeAnimationExtended.mjs.map +1 -1
- package/dist/es/animation/generators/inertia.mjs +3 -3
- package/dist/es/animation/generators/inertia.mjs.map +1 -1
- package/dist/es/animation/generators/spring.mjs +329 -0
- package/dist/es/animation/generators/spring.mjs.map +1 -0
- package/dist/es/animation/generators/utils/velocity.mjs +2 -2
- package/dist/es/animation/generators/utils/velocity.mjs.map +1 -1
- package/dist/es/animation/utils/replace-transition-type.mjs +1 -1
- package/dist/es/effects/MotionValueState.mjs +0 -5
- package/dist/es/effects/MotionValueState.mjs.map +1 -1
- package/dist/es/effects/style/transform.mjs +1 -2
- package/dist/es/effects/style/transform.mjs.map +1 -1
- package/dist/es/effects/utils/create-effect.mjs +1 -1
- package/dist/es/effects/utils/create-effect.mjs.map +1 -1
- package/dist/es/index.mjs +1 -1
- package/dist/es/projection/geometry/delta-apply.mjs +5 -4
- package/dist/es/projection/geometry/delta-apply.mjs.map +1 -1
- package/dist/es/projection/node/create-projection-node.mjs +17 -9
- package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
- package/dist/es/value/follow-value.mjs +19 -9
- package/dist/es/value/follow-value.mjs.map +1 -1
- package/dist/es/value/types/complex/index.mjs +27 -5
- package/dist/es/value/types/complex/index.mjs.map +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/motion-dom.dev.js +177 -76
- 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/es/animation/generators/spring/defaults.mjs +0 -28
- package/dist/es/animation/generators/spring/defaults.mjs.map +0 -1
- package/dist/es/animation/generators/spring/find.mjs +0 -85
- package/dist/es/animation/generators/spring/find.mjs.map +0 -1
- package/dist/es/animation/generators/spring/index.mjs +0 -181
- package/dist/es/animation/generators/spring/index.mjs.map +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -451,8 +451,7 @@ function analyseComplexValue(value) {
|
|
|
451
451
|
function parseComplexValue(v) {
|
|
452
452
|
return analyseComplexValue(v).values;
|
|
453
453
|
}
|
|
454
|
-
function
|
|
455
|
-
const { split, types } = analyseComplexValue(source);
|
|
454
|
+
function buildTransformer({ split, types }) {
|
|
456
455
|
const numSections = split.length;
|
|
457
456
|
return (v) => {
|
|
458
457
|
let output = "";
|
|
@@ -474,11 +473,34 @@ function createTransformer(source) {
|
|
|
474
473
|
return output;
|
|
475
474
|
};
|
|
476
475
|
}
|
|
476
|
+
function createTransformer(source) {
|
|
477
|
+
return buildTransformer(analyseComplexValue(source));
|
|
478
|
+
}
|
|
477
479
|
const convertNumbersToZero = (v) => typeof v === "number" ? 0 : color.test(v) ? color.getAnimatableNone(v) : v;
|
|
480
|
+
/**
|
|
481
|
+
* Convert a parsed value to its zero equivalent, but preserve numbers
|
|
482
|
+
* that act as divisors in CSS calc() expressions.
|
|
483
|
+
*
|
|
484
|
+
* analyseComplexValue extracts numbers from CSS strings and puts the
|
|
485
|
+
* surrounding text into a `split` template array. For example:
|
|
486
|
+
* "calc(var(--gap) / 5)" → values: [var(--gap), 5]
|
|
487
|
+
* split: ["calc(", " / ", ")"]
|
|
488
|
+
*
|
|
489
|
+
* When building a zero-equivalent for animation, naively zeroing all
|
|
490
|
+
* numbers turns the divisor into 0 → "calc(var(--gap) / 0)" → NaN.
|
|
491
|
+
* We detect this by checking whether the text preceding a number
|
|
492
|
+
* (split[i]) ends with "/" — the CSS calc division operator.
|
|
493
|
+
*/
|
|
494
|
+
const convertToZero = (value, splitBefore) => {
|
|
495
|
+
if (typeof value === "number") {
|
|
496
|
+
return splitBefore?.trim().endsWith("/") ? value : 0;
|
|
497
|
+
}
|
|
498
|
+
return convertNumbersToZero(value);
|
|
499
|
+
};
|
|
478
500
|
function getAnimatableNone$1(v) {
|
|
479
|
-
const
|
|
480
|
-
const transformer =
|
|
481
|
-
return transformer(
|
|
501
|
+
const info = analyseComplexValue(v);
|
|
502
|
+
const transformer = buildTransformer(info);
|
|
503
|
+
return transformer(info.values.map((value, i) => convertToZero(value, info.split[i])));
|
|
482
504
|
}
|
|
483
505
|
const complex = {
|
|
484
506
|
test,
|
|
@@ -757,12 +779,6 @@ function createGeneratorEasing(options, scale = 100, createGenerator) {
|
|
|
757
779
|
};
|
|
758
780
|
}
|
|
759
781
|
|
|
760
|
-
const velocitySampleDuration = 5; // ms
|
|
761
|
-
function calcGeneratorVelocity(resolveValue, t, current) {
|
|
762
|
-
const prevT = Math.max(t - velocitySampleDuration, 0);
|
|
763
|
-
return motionUtils.velocityPerSecond(current - resolveValue(prevT), t - prevT);
|
|
764
|
-
}
|
|
765
|
-
|
|
766
782
|
const springDefaults = {
|
|
767
783
|
// Default spring physics
|
|
768
784
|
stiffness: 100,
|
|
@@ -788,7 +804,20 @@ const springDefaults = {
|
|
|
788
804
|
minDamping: 0.05,
|
|
789
805
|
maxDamping: 1,
|
|
790
806
|
};
|
|
791
|
-
|
|
807
|
+
function calcAngularFreq(undampedFreq, dampingRatio) {
|
|
808
|
+
return undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
|
|
809
|
+
}
|
|
810
|
+
const rootIterations = 12;
|
|
811
|
+
function approximateRoot(envelope, derivative, initialGuess) {
|
|
812
|
+
let result = initialGuess;
|
|
813
|
+
for (let i = 1; i < rootIterations; i++) {
|
|
814
|
+
result = result - envelope(result) / derivative(result);
|
|
815
|
+
}
|
|
816
|
+
return result;
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* This is ported from the Framer implementation of duration-based spring resolution.
|
|
820
|
+
*/
|
|
792
821
|
const safeMin = 0.001;
|
|
793
822
|
function findSpring({ duration = springDefaults.duration, bounce = springDefaults.bounce, velocity = springDefaults.velocity, mass = springDefaults.mass, }) {
|
|
794
823
|
let envelope;
|
|
@@ -857,18 +886,6 @@ function findSpring({ duration = springDefaults.duration, bounce = springDefault
|
|
|
857
886
|
};
|
|
858
887
|
}
|
|
859
888
|
}
|
|
860
|
-
const rootIterations = 12;
|
|
861
|
-
function approximateRoot(envelope, derivative, initialGuess) {
|
|
862
|
-
let result = initialGuess;
|
|
863
|
-
for (let i = 1; i < rootIterations; i++) {
|
|
864
|
-
result = result - envelope(result) / derivative(result);
|
|
865
|
-
}
|
|
866
|
-
return result;
|
|
867
|
-
}
|
|
868
|
-
function calcAngularFreq(undampedFreq, dampingRatio) {
|
|
869
|
-
return undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
|
|
870
|
-
}
|
|
871
|
-
|
|
872
889
|
const durationKeys = ["duration", "bounce"];
|
|
873
890
|
const physicsKeys = ["stiffness", "damping", "mass"];
|
|
874
891
|
function isSpringType(options, keys) {
|
|
@@ -956,19 +973,37 @@ function spring(optionsOrVisualDuration = springDefaults.visualDuration, bounce
|
|
|
956
973
|
? springDefaults.restDelta.granular
|
|
957
974
|
: springDefaults.restDelta.default);
|
|
958
975
|
let resolveSpring;
|
|
976
|
+
let resolveVelocity;
|
|
977
|
+
// Underdamped coefficients, hoisted for use in the inlined next() hot path
|
|
978
|
+
let angularFreq;
|
|
979
|
+
let A;
|
|
980
|
+
let sinCoeff;
|
|
981
|
+
let cosCoeff;
|
|
959
982
|
if (dampingRatio < 1) {
|
|
960
|
-
|
|
983
|
+
angularFreq = calcAngularFreq(undampedAngularFreq, dampingRatio);
|
|
984
|
+
A =
|
|
985
|
+
(initialVelocity +
|
|
986
|
+
dampingRatio * undampedAngularFreq * initialDelta) /
|
|
987
|
+
angularFreq;
|
|
961
988
|
// Underdamped spring
|
|
962
989
|
resolveSpring = (t) => {
|
|
963
990
|
const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
|
|
964
991
|
return (target -
|
|
965
992
|
envelope *
|
|
966
|
-
((
|
|
967
|
-
dampingRatio * undampedAngularFreq * initialDelta) /
|
|
968
|
-
angularFreq) *
|
|
969
|
-
Math.sin(angularFreq * t) +
|
|
993
|
+
(A * Math.sin(angularFreq * t) +
|
|
970
994
|
initialDelta * Math.cos(angularFreq * t)));
|
|
971
995
|
};
|
|
996
|
+
// Analytical derivative of underdamped spring (px/ms)
|
|
997
|
+
sinCoeff =
|
|
998
|
+
dampingRatio * undampedAngularFreq * A + initialDelta * angularFreq;
|
|
999
|
+
cosCoeff =
|
|
1000
|
+
dampingRatio * undampedAngularFreq * initialDelta - A * angularFreq;
|
|
1001
|
+
resolveVelocity = (t) => {
|
|
1002
|
+
const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
|
|
1003
|
+
return envelope *
|
|
1004
|
+
(sinCoeff * Math.sin(angularFreq * t) +
|
|
1005
|
+
cosCoeff * Math.cos(angularFreq * t));
|
|
1006
|
+
};
|
|
972
1007
|
}
|
|
973
1008
|
else if (dampingRatio === 1) {
|
|
974
1009
|
// Critically damped spring
|
|
@@ -976,6 +1011,10 @@ function spring(optionsOrVisualDuration = springDefaults.visualDuration, bounce
|
|
|
976
1011
|
Math.exp(-undampedAngularFreq * t) *
|
|
977
1012
|
(initialDelta +
|
|
978
1013
|
(initialVelocity + undampedAngularFreq * initialDelta) * t);
|
|
1014
|
+
// Analytical derivative of critically damped spring (px/ms)
|
|
1015
|
+
const C = initialVelocity + undampedAngularFreq * initialDelta;
|
|
1016
|
+
resolveVelocity = (t) => Math.exp(-undampedAngularFreq * t) *
|
|
1017
|
+
(undampedAngularFreq * C * t - initialVelocity);
|
|
979
1018
|
}
|
|
980
1019
|
else {
|
|
981
1020
|
// Overdamped spring
|
|
@@ -994,28 +1033,50 @@ function spring(optionsOrVisualDuration = springDefaults.visualDuration, bounce
|
|
|
994
1033
|
Math.cosh(freqForT))) /
|
|
995
1034
|
dampedAngularFreq);
|
|
996
1035
|
};
|
|
1036
|
+
// Analytical derivative of overdamped spring (px/ms)
|
|
1037
|
+
const P = (initialVelocity +
|
|
1038
|
+
dampingRatio * undampedAngularFreq * initialDelta) /
|
|
1039
|
+
dampedAngularFreq;
|
|
1040
|
+
const sinhCoeff = dampingRatio * undampedAngularFreq * P - initialDelta * dampedAngularFreq;
|
|
1041
|
+
const coshCoeff = dampingRatio * undampedAngularFreq * initialDelta - P * dampedAngularFreq;
|
|
1042
|
+
resolveVelocity = (t) => {
|
|
1043
|
+
const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
|
|
1044
|
+
const freqForT = Math.min(dampedAngularFreq * t, 300);
|
|
1045
|
+
return envelope *
|
|
1046
|
+
(sinhCoeff * Math.sinh(freqForT) +
|
|
1047
|
+
coshCoeff * Math.cosh(freqForT));
|
|
1048
|
+
};
|
|
997
1049
|
}
|
|
998
1050
|
const generator = {
|
|
999
1051
|
calculatedDuration: isResolvedFromDuration ? duration || null : null,
|
|
1052
|
+
velocity: (t) => motionUtils.secondsToMilliseconds(resolveVelocity(t)),
|
|
1000
1053
|
next: (t) => {
|
|
1054
|
+
/**
|
|
1055
|
+
* For underdamped physics springs we need both position and
|
|
1056
|
+
* velocity each tick. Compute shared trig values once to avoid
|
|
1057
|
+
* duplicate Math.exp/sin/cos calls on the hot path.
|
|
1058
|
+
*/
|
|
1059
|
+
if (!isResolvedFromDuration && dampingRatio < 1) {
|
|
1060
|
+
const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
|
|
1061
|
+
const sin = Math.sin(angularFreq * t);
|
|
1062
|
+
const cos = Math.cos(angularFreq * t);
|
|
1063
|
+
const current = target -
|
|
1064
|
+
envelope *
|
|
1065
|
+
(A * sin + initialDelta * cos);
|
|
1066
|
+
const currentVelocity = motionUtils.secondsToMilliseconds(envelope *
|
|
1067
|
+
(sinCoeff * sin + cosCoeff * cos));
|
|
1068
|
+
state.done =
|
|
1069
|
+
Math.abs(currentVelocity) <= restSpeed &&
|
|
1070
|
+
Math.abs(target - current) <= restDelta;
|
|
1071
|
+
state.value = state.done ? target : current;
|
|
1072
|
+
return state;
|
|
1073
|
+
}
|
|
1001
1074
|
const current = resolveSpring(t);
|
|
1002
1075
|
if (!isResolvedFromDuration) {
|
|
1003
|
-
|
|
1004
|
-
/**
|
|
1005
|
-
* We only need to calculate velocity for under-damped springs
|
|
1006
|
-
* as over- and critically-damped springs can't overshoot, so
|
|
1007
|
-
* checking only for displacement is enough.
|
|
1008
|
-
*/
|
|
1009
|
-
if (dampingRatio < 1) {
|
|
1010
|
-
currentVelocity =
|
|
1011
|
-
t === 0
|
|
1012
|
-
? motionUtils.secondsToMilliseconds(initialVelocity)
|
|
1013
|
-
: calcGeneratorVelocity(resolveSpring, t, current);
|
|
1014
|
-
}
|
|
1015
|
-
const isBelowVelocityThreshold = Math.abs(currentVelocity) <= restSpeed;
|
|
1016
|
-
const isBelowDisplacementThreshold = Math.abs(target - current) <= restDelta;
|
|
1076
|
+
const currentVelocity = motionUtils.secondsToMilliseconds(resolveVelocity(t));
|
|
1017
1077
|
state.done =
|
|
1018
|
-
|
|
1078
|
+
Math.abs(currentVelocity) <= restSpeed &&
|
|
1079
|
+
Math.abs(target - current) <= restDelta;
|
|
1019
1080
|
}
|
|
1020
1081
|
else {
|
|
1021
1082
|
state.done = t >= duration;
|
|
@@ -1040,6 +1101,12 @@ spring.applyToOptions = (options) => {
|
|
|
1040
1101
|
return options;
|
|
1041
1102
|
};
|
|
1042
1103
|
|
|
1104
|
+
const velocitySampleDuration = 5; // ms
|
|
1105
|
+
function getGeneratorVelocity(resolveValue, t, current) {
|
|
1106
|
+
const prevT = Math.max(t - velocitySampleDuration, 0);
|
|
1107
|
+
return motionUtils.velocityPerSecond(current - resolveValue(prevT), t - prevT);
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1043
1110
|
function inertia({ keyframes, velocity = 0.0, power = 0.8, timeConstant = 325, bounceDamping = 10, bounceStiffness = 500, modifyTarget, min, max, restDelta = 0.5, restSpeed, }) {
|
|
1044
1111
|
const origin = keyframes[0];
|
|
1045
1112
|
const state = {
|
|
@@ -1085,7 +1152,7 @@ function inertia({ keyframes, velocity = 0.0, power = 0.8, timeConstant = 325, b
|
|
|
1085
1152
|
timeReachedBoundary = t;
|
|
1086
1153
|
spring$1 = spring({
|
|
1087
1154
|
keyframes: [state.value, nearestBoundary(state.value)],
|
|
1088
|
-
velocity:
|
|
1155
|
+
velocity: getGeneratorVelocity(calcLatest, t, state.value), // TODO: This should be passing * 1000
|
|
1089
1156
|
damping: bounceDamping,
|
|
1090
1157
|
stiffness: bounceStiffness,
|
|
1091
1158
|
restDelta,
|
|
@@ -1549,6 +1616,22 @@ class JSAnimation extends WithPromise {
|
|
|
1549
1616
|
this.tick(newTime);
|
|
1550
1617
|
}
|
|
1551
1618
|
}
|
|
1619
|
+
/**
|
|
1620
|
+
* Returns the generator's velocity at the current time in units/second.
|
|
1621
|
+
* Uses the analytical derivative when available (springs), avoiding
|
|
1622
|
+
* the MotionValue's frame-dependent velocity estimation.
|
|
1623
|
+
*/
|
|
1624
|
+
getGeneratorVelocity() {
|
|
1625
|
+
const t = this.currentTime;
|
|
1626
|
+
if (t <= 0)
|
|
1627
|
+
return this.options.velocity || 0;
|
|
1628
|
+
if (this.generator.velocity) {
|
|
1629
|
+
return this.generator.velocity(t);
|
|
1630
|
+
}
|
|
1631
|
+
// Fallback: finite difference
|
|
1632
|
+
const current = this.generator.next(t).value;
|
|
1633
|
+
return getGeneratorVelocity((s) => this.generator.next(s).value, t, current);
|
|
1634
|
+
}
|
|
1552
1635
|
get speed() {
|
|
1553
1636
|
return this.playbackSpeed;
|
|
1554
1637
|
}
|
|
@@ -2264,7 +2347,12 @@ class NativeAnimationExtended extends NativeAnimation {
|
|
|
2264
2347
|
*/
|
|
2265
2348
|
replaceTransitionType(options);
|
|
2266
2349
|
super(options);
|
|
2267
|
-
|
|
2350
|
+
/**
|
|
2351
|
+
* Only set startTime when the animation should autoplay.
|
|
2352
|
+
* Setting startTime on a paused WAAPI animation unpauses it
|
|
2353
|
+
* (per the WAAPI spec), which breaks autoplay: false.
|
|
2354
|
+
*/
|
|
2355
|
+
if (options.startTime !== undefined && options.autoplay !== false) {
|
|
2268
2356
|
this.startTime = options.startTime;
|
|
2269
2357
|
}
|
|
2270
2358
|
this.options = options;
|
|
@@ -4046,19 +4134,14 @@ class MotionValueState {
|
|
|
4046
4134
|
get(name) {
|
|
4047
4135
|
return this.values.get(name)?.value;
|
|
4048
4136
|
}
|
|
4049
|
-
destroy() {
|
|
4050
|
-
for (const value of this.values.values()) {
|
|
4051
|
-
value.onRemove();
|
|
4052
|
-
}
|
|
4053
|
-
}
|
|
4054
4137
|
}
|
|
4055
4138
|
|
|
4056
4139
|
function createEffect(addValue) {
|
|
4057
4140
|
const stateCache = new WeakMap();
|
|
4058
|
-
const subscriptions = [];
|
|
4059
4141
|
return (subject, values) => {
|
|
4060
4142
|
const state = stateCache.get(subject) ?? new MotionValueState();
|
|
4061
4143
|
stateCache.set(subject, state);
|
|
4144
|
+
const subscriptions = [];
|
|
4062
4145
|
for (const key in values) {
|
|
4063
4146
|
const value = values[key];
|
|
4064
4147
|
const remove = addValue(subject, state, key, value);
|
|
@@ -4150,8 +4233,7 @@ function buildTransform$1(state) {
|
|
|
4150
4233
|
if (!valueIsDefault) {
|
|
4151
4234
|
transformIsDefault = false;
|
|
4152
4235
|
const transformName = translateAlias$1[key] || key;
|
|
4153
|
-
|
|
4154
|
-
transform += `${transformName}(${valueToRender}) `;
|
|
4236
|
+
transform += `${transformName}(${value}) `;
|
|
4155
4237
|
}
|
|
4156
4238
|
}
|
|
4157
4239
|
return transformIsDefault ? "none" : transform.trim();
|
|
@@ -4859,16 +4941,23 @@ function attachFollow(value, source, options = {}) {
|
|
|
4859
4941
|
}
|
|
4860
4942
|
};
|
|
4861
4943
|
const startAnimation = () => {
|
|
4862
|
-
stopAnimation();
|
|
4863
4944
|
const currentValue = asNumber$1(value.get());
|
|
4864
4945
|
const targetValue = asNumber$1(latestValue);
|
|
4865
4946
|
// Don't animate if we're already at the target
|
|
4866
4947
|
if (currentValue === targetValue) {
|
|
4948
|
+
stopAnimation();
|
|
4867
4949
|
return;
|
|
4868
4950
|
}
|
|
4951
|
+
// Use the running animation's analytical velocity for accuracy,
|
|
4952
|
+
// falling back to the MotionValue's velocity for the initial animation.
|
|
4953
|
+
// This prevents systematic velocity loss at high frame rates (240hz+).
|
|
4954
|
+
const velocity = activeAnimation
|
|
4955
|
+
? activeAnimation.getGeneratorVelocity()
|
|
4956
|
+
: value.getVelocity();
|
|
4957
|
+
stopAnimation();
|
|
4869
4958
|
activeAnimation = new JSAnimation({
|
|
4870
4959
|
keyframes: [currentValue, targetValue],
|
|
4871
|
-
velocity
|
|
4960
|
+
velocity,
|
|
4872
4961
|
// Default to spring if no type specified (matches useSpring behavior)
|
|
4873
4962
|
type: "spring",
|
|
4874
4963
|
restDelta: 0.001,
|
|
@@ -4877,16 +4966,19 @@ function attachFollow(value, source, options = {}) {
|
|
|
4877
4966
|
onUpdate: latestSetter,
|
|
4878
4967
|
});
|
|
4879
4968
|
};
|
|
4969
|
+
// Use a stable function reference so the frame loop Set deduplicates
|
|
4970
|
+
// multiple calls within the same frame (e.g. rapid mouse events)
|
|
4971
|
+
const scheduleAnimation = () => {
|
|
4972
|
+
startAnimation();
|
|
4973
|
+
value["events"].animationStart?.notify();
|
|
4974
|
+
activeAnimation?.then(() => {
|
|
4975
|
+
value["events"].animationComplete?.notify();
|
|
4976
|
+
});
|
|
4977
|
+
};
|
|
4880
4978
|
value.attach((v, set) => {
|
|
4881
4979
|
latestValue = v;
|
|
4882
4980
|
latestSetter = (latest) => set(parseValue(latest, unit));
|
|
4883
|
-
frame.postRender(
|
|
4884
|
-
startAnimation();
|
|
4885
|
-
value["events"].animationStart?.notify();
|
|
4886
|
-
activeAnimation?.then(() => {
|
|
4887
|
-
value["events"].animationComplete?.notify();
|
|
4888
|
-
});
|
|
4889
|
-
});
|
|
4981
|
+
frame.postRender(scheduleAnimation);
|
|
4890
4982
|
}, stopAnimation);
|
|
4891
4983
|
if (isMotionValue(source)) {
|
|
4892
4984
|
const removeSourceOnChange = source.on("change", (v) => value.set(parseValue(v, unit)));
|
|
@@ -6182,7 +6274,7 @@ function applyTreeDeltas(box, treeScale, treePath, isSharedTransition = false) {
|
|
|
6182
6274
|
applyBoxDelta(box, delta);
|
|
6183
6275
|
}
|
|
6184
6276
|
if (isSharedTransition && hasTransform(node.latestValues)) {
|
|
6185
|
-
transformBox(box, node.latestValues);
|
|
6277
|
+
transformBox(box, node.latestValues, node.layout?.layoutBox);
|
|
6186
6278
|
}
|
|
6187
6279
|
}
|
|
6188
6280
|
/**
|
|
@@ -6221,9 +6313,10 @@ function resolveAxisTranslate(value, axis) {
|
|
|
6221
6313
|
/**
|
|
6222
6314
|
* Apply a transform to a box from the latest resolved motion values.
|
|
6223
6315
|
*/
|
|
6224
|
-
function transformBox(box, transform) {
|
|
6225
|
-
|
|
6226
|
-
transformAxis(box.
|
|
6316
|
+
function transformBox(box, transform, sourceBox) {
|
|
6317
|
+
const resolveBox = sourceBox ?? box;
|
|
6318
|
+
transformAxis(box.x, resolveAxisTranslate(transform.x, resolveBox.x), transform.scaleX, transform.scale, transform.originX);
|
|
6319
|
+
transformAxis(box.y, resolveAxisTranslate(transform.y, resolveBox.y), transform.scaleY, transform.scale, transform.originY);
|
|
6227
6320
|
}
|
|
6228
6321
|
|
|
6229
6322
|
function measureViewportBox(instance, transformPoint) {
|
|
@@ -7979,6 +8072,14 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
7979
8072
|
for (let i = 0; i < this.path.length; i++) {
|
|
7980
8073
|
const node = this.path[i];
|
|
7981
8074
|
node.shouldResetTransform = true;
|
|
8075
|
+
/**
|
|
8076
|
+
* Percentage translates resolve against layoutBox dimensions,
|
|
8077
|
+
* so ancestors with them must be re-measured after transform reset.
|
|
8078
|
+
*/
|
|
8079
|
+
if (typeof node.latestValues.x === "string" ||
|
|
8080
|
+
typeof node.latestValues.y === "string") {
|
|
8081
|
+
node.isLayoutDirty = true;
|
|
8082
|
+
}
|
|
7982
8083
|
node.updateScroll("snapshot");
|
|
7983
8084
|
if (node.options.layoutRoot) {
|
|
7984
8085
|
node.willUpdate(false);
|
|
@@ -8244,10 +8345,10 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
8244
8345
|
}
|
|
8245
8346
|
if (!hasTransform(node.latestValues))
|
|
8246
8347
|
continue;
|
|
8247
|
-
transformBox(withTransforms, node.latestValues);
|
|
8348
|
+
transformBox(withTransforms, node.latestValues, node.layout?.layoutBox);
|
|
8248
8349
|
}
|
|
8249
8350
|
if (hasTransform(this.latestValues)) {
|
|
8250
|
-
transformBox(withTransforms, this.latestValues);
|
|
8351
|
+
transformBox(withTransforms, this.latestValues, this.layout?.layoutBox);
|
|
8251
8352
|
}
|
|
8252
8353
|
return withTransforms;
|
|
8253
8354
|
}
|
|
@@ -8256,15 +8357,15 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
8256
8357
|
copyBoxInto(boxWithoutTransform, box);
|
|
8257
8358
|
for (let i = 0; i < this.path.length; i++) {
|
|
8258
8359
|
const node = this.path[i];
|
|
8259
|
-
if (!node.instance)
|
|
8260
|
-
continue;
|
|
8261
8360
|
if (!hasTransform(node.latestValues))
|
|
8262
8361
|
continue;
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8362
|
+
let sourceBox;
|
|
8363
|
+
if (node.instance) {
|
|
8364
|
+
hasScale(node.latestValues) && node.updateSnapshot();
|
|
8365
|
+
sourceBox = createBox();
|
|
8366
|
+
copyBoxInto(sourceBox, node.measurePageBox());
|
|
8367
|
+
}
|
|
8368
|
+
removeBoxTransforms(boxWithoutTransform, node.latestValues, node.snapshot?.layoutBox, sourceBox);
|
|
8268
8369
|
}
|
|
8269
8370
|
if (hasTransform(this.latestValues)) {
|
|
8270
8371
|
removeBoxTransforms(boxWithoutTransform, this.latestValues);
|