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
package/dist/motion-dom.dev.js
CHANGED
|
@@ -135,34 +135,21 @@
|
|
|
135
135
|
")",
|
|
136
136
|
};
|
|
137
137
|
|
|
138
|
+
/**
|
|
139
|
+
* #FF0000 has two characters per channel, #F00 one, which is doubled.
|
|
140
|
+
*/
|
|
141
|
+
const channel = (v, i, size) => {
|
|
142
|
+
const c = v.substring(1 + i * size, 1 + (i + 1) * size);
|
|
143
|
+
return size > 1 ? c : c + c;
|
|
144
|
+
};
|
|
138
145
|
function parseHex(v) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
let b = "";
|
|
142
|
-
let a = "";
|
|
143
|
-
// If we have 6 characters, ie #FF0000
|
|
144
|
-
if (v.length > 5) {
|
|
145
|
-
r = v.substring(1, 3);
|
|
146
|
-
g = v.substring(3, 5);
|
|
147
|
-
b = v.substring(5, 7);
|
|
148
|
-
a = v.substring(7, 9);
|
|
149
|
-
// Or we have 3 characters, ie #F00
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
r = v.substring(1, 2);
|
|
153
|
-
g = v.substring(2, 3);
|
|
154
|
-
b = v.substring(3, 4);
|
|
155
|
-
a = v.substring(4, 5);
|
|
156
|
-
r += r;
|
|
157
|
-
g += g;
|
|
158
|
-
b += b;
|
|
159
|
-
a += a;
|
|
160
|
-
}
|
|
146
|
+
const size = v.length > 5 ? 2 : 1;
|
|
147
|
+
const alpha = channel(v, 3, size);
|
|
161
148
|
return {
|
|
162
|
-
red: parseInt(
|
|
163
|
-
green: parseInt(
|
|
164
|
-
blue: parseInt(
|
|
165
|
-
alpha:
|
|
149
|
+
red: parseInt(channel(v, 0, size), 16),
|
|
150
|
+
green: parseInt(channel(v, 1, size), 16),
|
|
151
|
+
blue: parseInt(channel(v, 2, size), 16),
|
|
152
|
+
alpha: alpha ? parseInt(alpha, 16) / 255 : 1,
|
|
166
153
|
};
|
|
167
154
|
}
|
|
168
155
|
const hex = {
|
|
@@ -539,7 +526,6 @@
|
|
|
539
526
|
return orderedOrigin;
|
|
540
527
|
}
|
|
541
528
|
const mixComplex = (origin, target) => {
|
|
542
|
-
const template = complex.createTransformer(target);
|
|
543
529
|
const originStats = analyseComplexValue(origin);
|
|
544
530
|
const targetStats = analyseComplexValue(target);
|
|
545
531
|
const canInterpolate = originStats.indexes.var.length === targetStats.indexes.var.length &&
|
|
@@ -552,7 +538,7 @@
|
|
|
552
538
|
!originStats.values.length)) {
|
|
553
539
|
return mixVisibility(origin, target);
|
|
554
540
|
}
|
|
555
|
-
return motionUtils.pipe(mixArray(matchOrder(originStats, targetStats), targetStats.values),
|
|
541
|
+
return motionUtils.pipe(mixArray(matchOrder(originStats, targetStats), targetStats.values), buildTransformer(targetStats));
|
|
556
542
|
}
|
|
557
543
|
else {
|
|
558
544
|
motionUtils.warning(true, `Complex values '${origin}' and '${target}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`, "complex-values-different");
|
|
@@ -844,37 +830,31 @@
|
|
|
844
830
|
};
|
|
845
831
|
}
|
|
846
832
|
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
},
|
|
865
|
-
// Limits
|
|
866
|
-
minDuration: 0.01, // in seconds
|
|
867
|
-
maxDuration: 10.0, // in seconds
|
|
868
|
-
minDamping: 0.05,
|
|
869
|
-
};
|
|
833
|
+
// Default spring physics
|
|
834
|
+
const defaultStiffness = 100;
|
|
835
|
+
const defaultDamping = 10;
|
|
836
|
+
const defaultMass = 1.0;
|
|
837
|
+
// Default duration/bounce-based options
|
|
838
|
+
const defaultDuration = 800; // in ms
|
|
839
|
+
const defaultBounce = 0.3;
|
|
840
|
+
const defaultVisualDuration = 0.3; // in seconds
|
|
841
|
+
// Rest thresholds
|
|
842
|
+
const restSpeedGranular = 0.01;
|
|
843
|
+
const restSpeedDefault = 2;
|
|
844
|
+
const restDeltaGranular = 0.005;
|
|
845
|
+
const restDeltaDefault = 0.5;
|
|
846
|
+
// Limits
|
|
847
|
+
const minDuration = 0.01; // in seconds
|
|
848
|
+
const maxDuration = 10.0; // in seconds
|
|
849
|
+
const minDamping = 0.05;
|
|
870
850
|
/**
|
|
871
851
|
* Maps bounce to a damping ratio as SwiftUI does: 0 is critically damped, and
|
|
872
852
|
* it approaches undamped towards 1 and infinitely overdamped towards -1. Both
|
|
873
853
|
* ends are limited so the spring still moves and settles.
|
|
874
854
|
*/
|
|
875
855
|
const bounceToDampingRatio = (bounce) => bounce < 0
|
|
876
|
-
? 1 / Math.max(1 + bounce,
|
|
877
|
-
: Math.max(1 - bounce,
|
|
856
|
+
? 1 / Math.max(1 + bounce, minDamping)
|
|
857
|
+
: Math.max(1 - bounce, minDamping);
|
|
878
858
|
/**
|
|
879
859
|
* Scales an overdamped spring's undamped frequency so that, at its defining
|
|
880
860
|
* time, it has as far left to go as the critically damped spring that's
|
|
@@ -917,12 +897,12 @@
|
|
|
917
897
|
* ignore inherited velocity and only resolve without valid physics. Returns
|
|
918
898
|
* NaN physics when the root search doesn't converge.
|
|
919
899
|
*/
|
|
920
|
-
function findSpring({ duration =
|
|
900
|
+
function findSpring({ duration = defaultDuration, bounce = defaultBounce, }) {
|
|
921
901
|
let envelope;
|
|
922
902
|
let derivative;
|
|
923
|
-
motionUtils.warning(duration <= motionUtils.secondsToMilliseconds(
|
|
903
|
+
motionUtils.warning(duration <= motionUtils.secondsToMilliseconds(maxDuration), "Spring duration must be 10 seconds or less", "spring-duration-limit");
|
|
924
904
|
const dampingRatio = bounceToDampingRatio(bounce);
|
|
925
|
-
duration = motionUtils.clamp(
|
|
905
|
+
duration = motionUtils.clamp(minDuration, maxDuration, motionUtils.millisecondsToSeconds(duration));
|
|
926
906
|
if (dampingRatio < 1) {
|
|
927
907
|
/**
|
|
928
908
|
* Underdamped spring
|
|
@@ -1007,9 +987,9 @@
|
|
|
1007
987
|
const validMass = resolvePhysics(options.mass);
|
|
1008
988
|
const springOptions = {
|
|
1009
989
|
...options,
|
|
1010
|
-
stiffness: validStiffness ??
|
|
1011
|
-
damping: validDamping ??
|
|
1012
|
-
mass: validMass ??
|
|
990
|
+
stiffness: validStiffness ?? defaultStiffness,
|
|
991
|
+
damping: validDamping ?? defaultDamping,
|
|
992
|
+
mass: validMass ?? defaultMass,
|
|
1013
993
|
isResolvedFromDuration: false,
|
|
1014
994
|
// stiffness/damping/mass overrides duration/bounce
|
|
1015
995
|
isTimeDefined: (validStiffness ?? validDamping ?? validMass) === undefined &&
|
|
@@ -1037,13 +1017,13 @@
|
|
|
1037
1017
|
*/
|
|
1038
1018
|
if (!isValidPhysics(springOptions.stiffness) ||
|
|
1039
1019
|
!isValidPhysics(springOptions.damping, true)) {
|
|
1040
|
-
springOptions.stiffness =
|
|
1041
|
-
springOptions.damping =
|
|
1020
|
+
springOptions.stiffness = defaultStiffness;
|
|
1021
|
+
springOptions.damping = defaultDamping;
|
|
1042
1022
|
}
|
|
1043
1023
|
}
|
|
1044
1024
|
return springOptions;
|
|
1045
1025
|
}
|
|
1046
|
-
function springGenerator(optionsOrVisualDuration =
|
|
1026
|
+
function springGenerator(optionsOrVisualDuration = defaultVisualDuration, bounce = defaultBounce) {
|
|
1047
1027
|
const options = typeof optionsOrVisualDuration !== "object"
|
|
1048
1028
|
? {
|
|
1049
1029
|
visualDuration: optionsOrVisualDuration,
|
|
@@ -1093,14 +1073,10 @@
|
|
|
1093
1073
|
const isGranularScale = Math.abs(s.delta) < 5;
|
|
1094
1074
|
s.restSpeed =
|
|
1095
1075
|
options.restSpeed ||
|
|
1096
|
-
(isGranularScale
|
|
1097
|
-
? springDefaults.restSpeed.granular
|
|
1098
|
-
: springDefaults.restSpeed.default);
|
|
1076
|
+
(isGranularScale ? restSpeedGranular : restSpeedDefault);
|
|
1099
1077
|
s.restDelta =
|
|
1100
1078
|
options.restDelta ||
|
|
1101
|
-
(isGranularScale
|
|
1102
|
-
? springDefaults.restDelta.granular
|
|
1103
|
-
: springDefaults.restDelta.default);
|
|
1079
|
+
(isGranularScale ? restDeltaGranular : restDeltaDefault);
|
|
1104
1080
|
};
|
|
1105
1081
|
setRestThresholds();
|
|
1106
1082
|
let resolveSpring;
|
|
@@ -1169,11 +1145,16 @@
|
|
|
1169
1145
|
* dampedAngularFreq * t passes 300, both terms decay at the damping
|
|
1170
1146
|
* rate. Heavily overdamped drag springs (dragElastic: 0,
|
|
1171
1147
|
* dragTransition) rely on this to settle almost at once rather than
|
|
1172
|
-
* creep at stiffness / damping.
|
|
1173
|
-
*
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1148
|
+
* creep at stiffness / damping. It only applies when reached within
|
|
1149
|
+
* 300ms (a dampedAngularFreq of 1 rad/ms), so it reads as a stiff
|
|
1150
|
+
* spring snapping into place: any later and it cuts off a slow spring
|
|
1151
|
+
* that's visibly still moving (#1207). Negative bounce needs the
|
|
1152
|
+
* exact curve, so time-defined springs are exempt.
|
|
1153
|
+
*/
|
|
1154
|
+
const limit = dampedAngularFreq < 1 || isTimeDefined
|
|
1155
|
+
? Infinity
|
|
1156
|
+
: 300 / dampedAngularFreq;
|
|
1157
|
+
const decayAt = (rate, t) => Math.exp(t > limit ? (decay - rate) * limit - decay * t : -rate * t);
|
|
1177
1158
|
const c = { S: 0, F: 0 };
|
|
1178
1159
|
update = () => {
|
|
1179
1160
|
const P = (s.velocity + decay * s.delta) / dampedAngularFreq;
|
|
@@ -1254,7 +1235,7 @@
|
|
|
1254
1235
|
};
|
|
1255
1236
|
let amplitude = power * velocity;
|
|
1256
1237
|
const ideal = origin + amplitude;
|
|
1257
|
-
const target = modifyTarget
|
|
1238
|
+
const target = modifyTarget ? modifyTarget(ideal) : ideal;
|
|
1258
1239
|
/**
|
|
1259
1240
|
* If the target has changed we need to re-calculate the amplitude, otherwise
|
|
1260
1241
|
* the animation will start from the wrong position.
|
|
@@ -1265,7 +1246,8 @@
|
|
|
1265
1246
|
const applyFriction = (t) => {
|
|
1266
1247
|
const delta = calcDelta(t);
|
|
1267
1248
|
state.done = Math.abs(delta) <= restDelta;
|
|
1268
|
-
|
|
1249
|
+
// target + delta can be off from origin by a float error at t = 0
|
|
1250
|
+
state.value = state.done ? target : t ? target + delta : origin;
|
|
1269
1251
|
};
|
|
1270
1252
|
/**
|
|
1271
1253
|
* Ideally this would resolve for t in a stateless way, we could
|
|
@@ -1711,17 +1693,12 @@
|
|
|
1711
1693
|
this.generator = generator;
|
|
1712
1694
|
}
|
|
1713
1695
|
updateTime(timestamp) {
|
|
1714
|
-
|
|
1715
|
-
//
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
// Rounding the time because floating point arithmetic is not always accurate, e.g. 3000.367 - 1000.367 =
|
|
1721
|
-
// 2000.0000000000002. This is a problem when we are comparing the currentTime with the duration, for
|
|
1722
|
-
// example.
|
|
1723
|
-
this.currentTime = animationTime;
|
|
1724
|
-
}
|
|
1696
|
+
// Rounding the time because floating point arithmetic is not always accurate, e.g. 3000.367 - 1000.367 =
|
|
1697
|
+
// 2000.0000000000002. This is a problem when we are comparing the currentTime with the duration, for
|
|
1698
|
+
// example.
|
|
1699
|
+
this.currentTime =
|
|
1700
|
+
this.holdTime ??
|
|
1701
|
+
Math.round(timestamp - this.startTime) * this.playbackSpeed;
|
|
1725
1702
|
}
|
|
1726
1703
|
tick(timestamp, sample = false) {
|
|
1727
1704
|
const { generator, totalDuration, calculatedDuration } = this;
|
|
@@ -1762,10 +1739,17 @@
|
|
|
1762
1739
|
}
|
|
1763
1740
|
const state = this.generate(this.currentTime, isInDelayPhase);
|
|
1764
1741
|
let { done } = state;
|
|
1765
|
-
|
|
1742
|
+
/**
|
|
1743
|
+
* A generator that takes longer than maxGeneratorDuration to finish
|
|
1744
|
+
* has an Infinity duration, so played forwards it finishes when it
|
|
1745
|
+
* says it's done.
|
|
1746
|
+
*/
|
|
1747
|
+
if (!isInDelayPhase) {
|
|
1766
1748
|
done =
|
|
1767
1749
|
this.playbackSpeed >= 0
|
|
1768
|
-
?
|
|
1750
|
+
? calculatedDuration < Infinity
|
|
1751
|
+
? this.currentTime >= totalDuration
|
|
1752
|
+
: done
|
|
1769
1753
|
: this.currentTime <= 0;
|
|
1770
1754
|
}
|
|
1771
1755
|
const isAnimationFinished = this.holdTime === null &&
|
|
@@ -1871,20 +1855,11 @@
|
|
|
1871
1855
|
}
|
|
1872
1856
|
return state;
|
|
1873
1857
|
}
|
|
1874
|
-
/**
|
|
1875
|
-
* Allows the returned animation to be awaited or promise-chained. Currently
|
|
1876
|
-
* resolves when the animation finishes at all but in a future update could/should
|
|
1877
|
-
* reject if its cancels.
|
|
1878
|
-
*/
|
|
1879
|
-
then(resolve, reject) {
|
|
1880
|
-
return this.finished.then(resolve, reject);
|
|
1881
|
-
}
|
|
1882
1858
|
get duration() {
|
|
1883
1859
|
return motionUtils.millisecondsToSeconds(this.calculatedDuration);
|
|
1884
1860
|
}
|
|
1885
1861
|
get iterationDuration() {
|
|
1886
|
-
|
|
1887
|
-
return this.duration + motionUtils.millisecondsToSeconds(delay);
|
|
1862
|
+
return this.duration + motionUtils.millisecondsToSeconds(this.options.delay ?? 0);
|
|
1888
1863
|
}
|
|
1889
1864
|
get time() {
|
|
1890
1865
|
return motionUtils.millisecondsToSeconds(this.currentTime);
|
|
@@ -1988,14 +1963,9 @@
|
|
|
1988
1963
|
}
|
|
1989
1964
|
teardown() {
|
|
1990
1965
|
this.state = "idle";
|
|
1991
|
-
this.
|
|
1992
|
-
this.startTime = this.holdTime = null;
|
|
1993
|
-
}
|
|
1994
|
-
stopDriver() {
|
|
1995
|
-
if (!this.driver)
|
|
1996
|
-
return;
|
|
1997
|
-
this.driver.stop();
|
|
1966
|
+
this.driver?.stop();
|
|
1998
1967
|
this.driver = undefined;
|
|
1968
|
+
this.startTime = this.holdTime = null;
|
|
1999
1969
|
}
|
|
2000
1970
|
sample(sampleTime) {
|
|
2001
1971
|
this.startTime = 0;
|
|
@@ -2252,23 +2222,15 @@
|
|
|
2252
2222
|
if (!transform || transform === "none") {
|
|
2253
2223
|
return defaultTransformValue(name);
|
|
2254
2224
|
}
|
|
2255
|
-
const
|
|
2256
|
-
let parsers;
|
|
2257
|
-
let match;
|
|
2258
|
-
if (matrix3dMatch) {
|
|
2259
|
-
parsers = matrix3dParsers;
|
|
2260
|
-
match = matrix3dMatch;
|
|
2261
|
-
}
|
|
2262
|
-
else {
|
|
2263
|
-
const matrix2dMatch = transform.match(/^matrix\(([-\d.e\s,]+)\)$/u);
|
|
2264
|
-
parsers = matrix2dParsers;
|
|
2265
|
-
match = matrix2dMatch;
|
|
2266
|
-
}
|
|
2225
|
+
const match = transform.match(/^matrix(3d)?\(([-\d.e\s,]+)\)$/u);
|
|
2267
2226
|
if (!match) {
|
|
2268
2227
|
return defaultTransformValue(name);
|
|
2269
2228
|
}
|
|
2270
|
-
const valueParser =
|
|
2271
|
-
|
|
2229
|
+
const valueParser = (match[1] ? matrix3dParsers : matrix2dParsers)[name];
|
|
2230
|
+
/**
|
|
2231
|
+
* parseFloat skips leading whitespace and stops at trailing whitespace.
|
|
2232
|
+
*/
|
|
2233
|
+
const values = match[2].split(",").map((v) => parseFloat(v));
|
|
2272
2234
|
return typeof valueParser === "function"
|
|
2273
2235
|
? valueParser(values)
|
|
2274
2236
|
: values[valueParser];
|
|
@@ -2277,9 +2239,6 @@
|
|
|
2277
2239
|
const { transform = "none" } = getComputedStyle(instance);
|
|
2278
2240
|
return parseValueFromTransform(transform, name);
|
|
2279
2241
|
};
|
|
2280
|
-
function convertTransformToNumber(value) {
|
|
2281
|
-
return parseFloat(value.trim());
|
|
2282
|
-
}
|
|
2283
2242
|
|
|
2284
2243
|
/**
|
|
2285
2244
|
* Generate a list of every possible transform key.
|
|
@@ -2682,7 +2641,9 @@
|
|
|
2682
2641
|
this.isPseudoElement = Boolean(pseudoElement);
|
|
2683
2642
|
this.allowFlatten = allowFlatten;
|
|
2684
2643
|
this.options = options;
|
|
2685
|
-
|
|
2644
|
+
typeof process !== "undefined" &&
|
|
2645
|
+
"development" !== "production" &&
|
|
2646
|
+
motionUtils.invariant(typeof options.type !== "string", `Mini animate() doesn't support "type" as a string.`, "mini-spring");
|
|
2686
2647
|
const transition = applyGeneratorOptions(options);
|
|
2687
2648
|
this.animation = startWaapiAnimation(element, name, keyframes, transition, pseudoElement);
|
|
2688
2649
|
if (transition.autoplay === false) {
|
|
@@ -2692,9 +2653,7 @@
|
|
|
2692
2653
|
this.finishedTime = this.time;
|
|
2693
2654
|
if (!pseudoElement) {
|
|
2694
2655
|
const keyframe = getFinalKeyframe(keyframes, this.options, finalKeyframe, this.speed);
|
|
2695
|
-
|
|
2696
|
-
this.updateMotionValue(keyframe);
|
|
2697
|
-
}
|
|
2656
|
+
this.updateMotionValue?.(keyframe);
|
|
2698
2657
|
/**
|
|
2699
2658
|
* If we can, we want to commit the final style as set by the user,
|
|
2700
2659
|
* rather than the computed keyframe value supplied by the animation.
|
|
@@ -3015,6 +2974,7 @@
|
|
|
3015
2974
|
if (!isOriginAnimatable || !isTargetAnimatable) {
|
|
3016
2975
|
// Only build the message when we're going to warn
|
|
3017
2976
|
isOriginAnimatable !== isTargetAnimatable &&
|
|
2977
|
+
"development" !== "production" &&
|
|
3018
2978
|
motionUtils.warning(false, `You are trying to animate ${name} from "${originKeyframe}" to "${targetKeyframe}". "${isOriginAnimatable ? targetKeyframe : originKeyframe}" is not an animatable value.`, "value-not-animatable");
|
|
3019
2979
|
return false;
|
|
3020
2980
|
}
|
|
@@ -3029,13 +2989,16 @@
|
|
|
3029
2989
|
|
|
3030
2990
|
/**
|
|
3031
2991
|
* A list of values that can be hardware-accelerated.
|
|
2992
|
+
*
|
|
2993
|
+
* Colors aren't included: WAAPI mixes them in sRGB, but JS animations
|
|
2994
|
+
* (and the sampler that estimates a WAAPI value on interrupt) mix them
|
|
2995
|
+
* in linear color space, so interrupting one would visibly jump.
|
|
3032
2996
|
*/
|
|
3033
2997
|
const acceleratedValues = new Set([
|
|
3034
2998
|
"opacity",
|
|
3035
2999
|
"clipPath",
|
|
3036
3000
|
"filter",
|
|
3037
3001
|
"transform",
|
|
3038
|
-
"backgroundColor",
|
|
3039
3002
|
]);
|
|
3040
3003
|
|
|
3041
3004
|
const browserColorFunctions = /^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;
|
|
@@ -3127,6 +3090,20 @@
|
|
|
3127
3090
|
transformPerspective: "perspective",
|
|
3128
3091
|
};
|
|
3129
3092
|
const numTransforms = transformPropOrder.length;
|
|
3093
|
+
/**
|
|
3094
|
+
* Cache of `translateX(`-style openers so each transform function is a few
|
|
3095
|
+
* string concatenations rather than a template.
|
|
3096
|
+
*/
|
|
3097
|
+
const openers = {};
|
|
3098
|
+
/**
|
|
3099
|
+
* A transform function, e.g. `translateX(10px)` for `x: 10`.
|
|
3100
|
+
*/
|
|
3101
|
+
const transformFunction = (key, value, valueAsType = getValueAsType(value, transformValueTypes[key])) => (openers[key] || (openers[key] = (translateAlias[key] || key) + "(")) + valueAsType + ")";
|
|
3102
|
+
/**
|
|
3103
|
+
* Whether a transform value is at its default, so can be left out.
|
|
3104
|
+
*/
|
|
3105
|
+
const isDefaultTransform = (key, value) => (typeof value === "number" ? value : parseFloat(value)) ===
|
|
3106
|
+
(key.startsWith("scale") ? 1 : 0);
|
|
3130
3107
|
/**
|
|
3131
3108
|
* Build a CSS transform style from individual x/y/scale etc properties.
|
|
3132
3109
|
*
|
|
@@ -3136,7 +3113,6 @@
|
|
|
3136
3113
|
function buildTransform$1(latestValues, transform, transformTemplate) {
|
|
3137
3114
|
// The transform string we're going to build into.
|
|
3138
3115
|
let transformString = "";
|
|
3139
|
-
let transformIsDefault = true;
|
|
3140
3116
|
/**
|
|
3141
3117
|
* Loop over all possible transforms in order, adding the ones that
|
|
3142
3118
|
* are present to the transform string.
|
|
@@ -3146,24 +3122,11 @@
|
|
|
3146
3122
|
const value = latestValues[key];
|
|
3147
3123
|
if (value === undefined)
|
|
3148
3124
|
continue;
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
const parsed = parseFloat(value);
|
|
3155
|
-
valueIsDefault = key.startsWith("scale") ? parsed === 1 : parsed === 0;
|
|
3156
|
-
}
|
|
3157
|
-
if (!valueIsDefault || transformTemplate) {
|
|
3158
|
-
const valueAsType = getValueAsType(value, numberValueTypes[key]);
|
|
3159
|
-
if (!valueIsDefault) {
|
|
3160
|
-
transformIsDefault = false;
|
|
3161
|
-
const transformName = translateAlias[key] || key;
|
|
3162
|
-
transformString += `${transformName}(${valueAsType}) `;
|
|
3163
|
-
}
|
|
3164
|
-
if (transformTemplate) {
|
|
3165
|
-
transform[key] = valueAsType;
|
|
3166
|
-
}
|
|
3125
|
+
const valueAsType = transformTemplate &&
|
|
3126
|
+
(transform[key] = getValueAsType(value, numberValueTypes[key]));
|
|
3127
|
+
if (!isDefaultTransform(key, value)) {
|
|
3128
|
+
transformString +=
|
|
3129
|
+
transformFunction(key, value, valueAsType || undefined) + " ";
|
|
3167
3130
|
}
|
|
3168
3131
|
}
|
|
3169
3132
|
// `pathRotation` composes onto `rotate` as a separate additive term so
|
|
@@ -3171,19 +3134,14 @@
|
|
|
3171
3134
|
// `transformPropOrder`.
|
|
3172
3135
|
const pathRotation = latestValues.pathRotation;
|
|
3173
3136
|
if (pathRotation) {
|
|
3174
|
-
|
|
3175
|
-
transformString += `rotate(${getValueAsType(pathRotation, numberValueTypes.pathRotation)}) `;
|
|
3137
|
+
transformString += transformFunction("rotate", pathRotation);
|
|
3176
3138
|
}
|
|
3177
3139
|
transformString = transformString.trim();
|
|
3178
3140
|
// If we have a custom `transform` template, pass our transform values and
|
|
3179
3141
|
// generated transformString to that before returning
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
else if (transformIsDefault) {
|
|
3184
|
-
transformString = "none";
|
|
3185
|
-
}
|
|
3186
|
-
return transformString;
|
|
3142
|
+
return transformTemplate
|
|
3143
|
+
? transformTemplate(transform, transformString)
|
|
3144
|
+
: transformString || "none";
|
|
3187
3145
|
}
|
|
3188
3146
|
|
|
3189
3147
|
const transformGroups = new WeakMap();
|
|
@@ -3525,27 +3483,30 @@
|
|
|
3525
3483
|
return values;
|
|
3526
3484
|
};
|
|
3527
3485
|
/**
|
|
3528
|
-
* Build
|
|
3529
|
-
* is written, even at its default, so each keyframe has the
|
|
3530
|
-
* of functions and the browser interpolates them one by one.
|
|
3486
|
+
* Build a transform from values in transformPropOrder. For a keyframe,
|
|
3487
|
+
* every key is written, even at its default, so each keyframe has the
|
|
3488
|
+
* same list of functions and the browser interpolates them one by one.
|
|
3489
|
+
* As an inline style, defaults are left out, as buildTransform does.
|
|
3531
3490
|
*/
|
|
3532
|
-
const
|
|
3491
|
+
const toTransform = (values, isStyle) => {
|
|
3533
3492
|
let transform = "";
|
|
3534
|
-
const values = valuesAt(timestamp, settled);
|
|
3535
3493
|
for (const key in values) {
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
") ";
|
|
3494
|
+
const value = values[key];
|
|
3495
|
+
if (!isStyle || !isDefaultTransform(key, value)) {
|
|
3496
|
+
transform += transformFunction(key, value) + " ";
|
|
3497
|
+
}
|
|
3541
3498
|
}
|
|
3542
|
-
return transform || "none";
|
|
3499
|
+
return (isStyle ? transform.trim() : transform) || "none";
|
|
3543
3500
|
};
|
|
3501
|
+
/**
|
|
3502
|
+
* Build the transform at a timestamp.
|
|
3503
|
+
*/
|
|
3504
|
+
const compose = (timestamp, settled) => toTransform(valuesAt(timestamp, settled));
|
|
3544
3505
|
/**
|
|
3545
3506
|
* Write the transform as an inline style, as the renderer would.
|
|
3546
3507
|
*/
|
|
3547
3508
|
const commit = (values = valuesAt()) => {
|
|
3548
|
-
element.style.transform =
|
|
3509
|
+
element.style.transform = toTransform(values, true);
|
|
3549
3510
|
};
|
|
3550
3511
|
/**
|
|
3551
3512
|
* Cancel the WAAPI animations, by default first committing the
|
|
@@ -3556,6 +3517,13 @@
|
|
|
3556
3517
|
segments.forEach(({ animation }) => animation.cancel());
|
|
3557
3518
|
segments = [];
|
|
3558
3519
|
};
|
|
3520
|
+
/**
|
|
3521
|
+
* A WAAPI animation that add() starts by setting its startTime. Playing
|
|
3522
|
+
* it first, as element.animate() does, would leave WebKit holding that
|
|
3523
|
+
* play's ready time once startTime ends the play, and it uses that for
|
|
3524
|
+
* the next updatePlaybackRate(), so the animation would jump.
|
|
3525
|
+
*/
|
|
3526
|
+
const create = (keyframes, options) => new Animation(new KeyframeEffect(element, keyframes, options));
|
|
3559
3527
|
const add = (animation, offset, end = Infinity) => {
|
|
3560
3528
|
const segment = { animation, offset, end };
|
|
3561
3529
|
animation.startTime = time.now() + offset;
|
|
@@ -3748,7 +3716,7 @@
|
|
|
3748
3716
|
commit(valuesAt(from, settled));
|
|
3749
3717
|
keyframes = null;
|
|
3750
3718
|
}
|
|
3751
|
-
return
|
|
3719
|
+
return create(keyframes, {
|
|
3752
3720
|
...options,
|
|
3753
3721
|
duration: to - from,
|
|
3754
3722
|
easing: easing || "linear",
|
|
@@ -3838,9 +3806,7 @@
|
|
|
3838
3806
|
* empty animations that end with them.
|
|
3839
3807
|
*/
|
|
3840
3808
|
ends.forEach((trackEnd) => trackEnd < end - 1 &&
|
|
3841
|
-
add(
|
|
3842
|
-
duration: trackEnd - now,
|
|
3843
|
-
}), 0, trackEnd - now));
|
|
3809
|
+
add(create(null, { duration: trackEnd - now }), 0, trackEnd - now));
|
|
3844
3810
|
}
|
|
3845
3811
|
if (cycle) {
|
|
3846
3812
|
/**
|
|
@@ -3914,12 +3880,29 @@
|
|
|
3914
3880
|
if (isDone)
|
|
3915
3881
|
continue;
|
|
3916
3882
|
const local = elapsed - offset;
|
|
3917
|
-
if (rate
|
|
3883
|
+
if (rate &&
|
|
3884
|
+
animation.updatePlaybackRate &&
|
|
3885
|
+
animation.playState === "running" &&
|
|
3886
|
+
Math.abs(Number(animation.currentTime) - local) < 20) {
|
|
3887
|
+
/**
|
|
3888
|
+
* Only the speed changed. Setting playbackRate and
|
|
3889
|
+
* startTime restarts a running compositor animation, which
|
|
3890
|
+
* can render the underlying value for a frame.
|
|
3891
|
+
*/
|
|
3892
|
+
animation.playbackRate !== rate &&
|
|
3893
|
+
animation.updatePlaybackRate(rate);
|
|
3894
|
+
}
|
|
3895
|
+
else if (rate) {
|
|
3918
3896
|
animation.playbackRate = rate;
|
|
3919
3897
|
animation.startTime = now - local / rate;
|
|
3920
3898
|
}
|
|
3921
3899
|
else {
|
|
3922
|
-
|
|
3900
|
+
/**
|
|
3901
|
+
* Hold it without pause(), whose pending pause setting
|
|
3902
|
+
* currentTime would end at once, leaving WebKit holding its
|
|
3903
|
+
* ready time (see create()).
|
|
3904
|
+
*/
|
|
3905
|
+
animation.startTime = null;
|
|
3923
3906
|
animation.currentTime = local;
|
|
3924
3907
|
}
|
|
3925
3908
|
}
|
|
@@ -4066,6 +4049,7 @@
|
|
|
4066
4049
|
built = new Map();
|
|
4067
4050
|
stop();
|
|
4068
4051
|
tracks.forEach((track) => track.state === "running" && track.js?.start());
|
|
4052
|
+
return true;
|
|
4069
4053
|
},
|
|
4070
4054
|
};
|
|
4071
4055
|
transformGroups.set(element, group);
|
|
@@ -4110,9 +4094,8 @@
|
|
|
4110
4094
|
* If we can't animate this value with the resolved keyframes
|
|
4111
4095
|
* then we should complete it immediately.
|
|
4112
4096
|
*/
|
|
4113
|
-
|
|
4114
|
-
if (!
|
|
4115
|
-
canAnimateValue = false;
|
|
4097
|
+
const canAnimateValue = canAnimate(keyframes, name, type, velocity);
|
|
4098
|
+
if (!canAnimateValue) {
|
|
4116
4099
|
if (motionUtils.MotionGlobalConfig.instantAnimations || !delay) {
|
|
4117
4100
|
onUpdate?.(getFinalKeyframe(keyframes, options, finalKeyframe));
|
|
4118
4101
|
}
|
|
@@ -4256,9 +4239,7 @@
|
|
|
4256
4239
|
this.animation.complete();
|
|
4257
4240
|
}
|
|
4258
4241
|
cancel() {
|
|
4259
|
-
|
|
4260
|
-
this.animation.cancel();
|
|
4261
|
-
}
|
|
4242
|
+
this._animation?.cancel();
|
|
4262
4243
|
this.keyframeResolver?.cancel();
|
|
4263
4244
|
}
|
|
4264
4245
|
}
|
|
@@ -4441,7 +4422,7 @@
|
|
|
4441
4422
|
this.setCurrent(v);
|
|
4442
4423
|
// Update update subscribers
|
|
4443
4424
|
if (this.current !== this.prev) {
|
|
4444
|
-
this.
|
|
4425
|
+
this.dirty();
|
|
4445
4426
|
if (this.dependents) {
|
|
4446
4427
|
for (const dependent of this.dependents) {
|
|
4447
4428
|
dependent.dirty();
|
|
@@ -4579,12 +4560,9 @@
|
|
|
4579
4560
|
* @public
|
|
4580
4561
|
*/
|
|
4581
4562
|
set(v) {
|
|
4582
|
-
|
|
4583
|
-
this.
|
|
4584
|
-
|
|
4585
|
-
else {
|
|
4586
|
-
this.passiveEffect(v, this.updateAndNotify);
|
|
4587
|
-
}
|
|
4563
|
+
this.passiveEffect
|
|
4564
|
+
? this.passiveEffect(v, this.updateAndNotify)
|
|
4565
|
+
: this.updateAndNotify(v);
|
|
4588
4566
|
}
|
|
4589
4567
|
setWithVelocity(prev, current, delta) {
|
|
4590
4568
|
this.set(current);
|
|
@@ -4601,13 +4579,9 @@
|
|
|
4601
4579
|
this.prev = v;
|
|
4602
4580
|
this.prevUpdatedAt = this.prevFrameValue = undefined;
|
|
4603
4581
|
endAnimation && this.stop();
|
|
4604
|
-
|
|
4605
|
-
this.stopPassiveEffect();
|
|
4582
|
+
this.stopPassiveEffect?.();
|
|
4606
4583
|
}
|
|
4607
4584
|
dirty() {
|
|
4608
|
-
this.notifyChange();
|
|
4609
|
-
}
|
|
4610
|
-
notifyChange() {
|
|
4611
4585
|
const { current, changeSubscriber } = this;
|
|
4612
4586
|
/**
|
|
4613
4587
|
* One or the other exists. Subscribing during the direct
|
|
@@ -4622,15 +4596,10 @@
|
|
|
4622
4596
|
}
|
|
4623
4597
|
}
|
|
4624
4598
|
addDependent(dependent) {
|
|
4625
|
-
|
|
4626
|
-
this.dependents = new Set();
|
|
4627
|
-
}
|
|
4628
|
-
this.dependents.add(dependent);
|
|
4599
|
+
(this.dependents || (this.dependents = new Set())).add(dependent);
|
|
4629
4600
|
}
|
|
4630
4601
|
removeDependent(dependent) {
|
|
4631
|
-
|
|
4632
|
-
this.dependents.delete(dependent);
|
|
4633
|
-
}
|
|
4602
|
+
this.dependents?.delete(dependent);
|
|
4634
4603
|
}
|
|
4635
4604
|
/**
|
|
4636
4605
|
* Returns the latest state of `MotionValue`
|
|
@@ -4640,9 +4609,7 @@
|
|
|
4640
4609
|
* @public
|
|
4641
4610
|
*/
|
|
4642
4611
|
get() {
|
|
4643
|
-
|
|
4644
|
-
collectMotionValues.current.push(this);
|
|
4645
|
-
}
|
|
4612
|
+
collectMotionValues.current?.push(this);
|
|
4646
4613
|
/**
|
|
4647
4614
|
* A value animating on the compositor isn't updated every frame,
|
|
4648
4615
|
* so read it from its animation.
|
|
@@ -4708,7 +4675,7 @@
|
|
|
4708
4675
|
isComplete = true;
|
|
4709
4676
|
this.events.animationComplete?.notify();
|
|
4710
4677
|
if (this.animation === animation)
|
|
4711
|
-
this.
|
|
4678
|
+
this.animation = undefined;
|
|
4712
4679
|
resolve();
|
|
4713
4680
|
});
|
|
4714
4681
|
if (!isComplete)
|
|
@@ -4724,11 +4691,10 @@
|
|
|
4724
4691
|
stop() {
|
|
4725
4692
|
if (this.animation) {
|
|
4726
4693
|
this.animation.stop();
|
|
4727
|
-
|
|
4728
|
-
this.events.animationCancel.notify();
|
|
4729
|
-
}
|
|
4694
|
+
this.events.animationCancel?.notify();
|
|
4730
4695
|
}
|
|
4731
|
-
|
|
4696
|
+
// Assign rather than delete to keep the object's shape stable
|
|
4697
|
+
this.animation = undefined;
|
|
4732
4698
|
}
|
|
4733
4699
|
/**
|
|
4734
4700
|
* Returns `true` if this value is currently animating.
|
|
@@ -4738,10 +4704,6 @@
|
|
|
4738
4704
|
isAnimating() {
|
|
4739
4705
|
return !!this.animation;
|
|
4740
4706
|
}
|
|
4741
|
-
clearAnimation() {
|
|
4742
|
-
// Assign rather than delete to keep the object's shape stable
|
|
4743
|
-
this.animation = undefined;
|
|
4744
|
-
}
|
|
4745
4707
|
/**
|
|
4746
4708
|
* Destroy and clean up subscribers to this `MotionValue`.
|
|
4747
4709
|
*
|
|
@@ -4756,9 +4718,7 @@
|
|
|
4756
4718
|
this.events.destroy?.notify();
|
|
4757
4719
|
this.clearListeners();
|
|
4758
4720
|
this.stop();
|
|
4759
|
-
|
|
4760
|
-
this.stopPassiveEffect();
|
|
4761
|
-
}
|
|
4721
|
+
this.stopPassiveEffect?.();
|
|
4762
4722
|
}
|
|
4763
4723
|
}
|
|
4764
4724
|
function motionValue(init, options) {
|
|
@@ -4836,6 +4796,7 @@
|
|
|
4836
4796
|
"repeatDelay",
|
|
4837
4797
|
"from",
|
|
4838
4798
|
"elapsed",
|
|
4799
|
+
"out",
|
|
4839
4800
|
]);
|
|
4840
4801
|
/**
|
|
4841
4802
|
* Decide whether a transition is defined on a given Transition.
|
|
@@ -5306,7 +5267,7 @@
|
|
|
5306
5267
|
}
|
|
5307
5268
|
const valueTransition = {
|
|
5308
5269
|
delay,
|
|
5309
|
-
...getValueTransition(transition || {}, key),
|
|
5270
|
+
...getValueTransition(animationTypeState?.out[key] || transition || {}, key),
|
|
5310
5271
|
};
|
|
5311
5272
|
if (skipAnimations)
|
|
5312
5273
|
valueTransition.skipAnimations = true;
|
|
@@ -5476,8 +5437,9 @@
|
|
|
5476
5437
|
}
|
|
5477
5438
|
|
|
5478
5439
|
class DOMKeyframesResolver extends KeyframeResolver {
|
|
5479
|
-
constructor(
|
|
5480
|
-
super(
|
|
5440
|
+
constructor() {
|
|
5441
|
+
super(...arguments);
|
|
5442
|
+
this.isAsync = true;
|
|
5481
5443
|
}
|
|
5482
5444
|
/**
|
|
5483
5445
|
* Keyframes that don't need reading from the DOM, or measuring,
|
|
@@ -5505,7 +5467,7 @@
|
|
|
5505
5467
|
}
|
|
5506
5468
|
readKeyframes() {
|
|
5507
5469
|
const { unresolvedKeyframes, element, name } = this;
|
|
5508
|
-
if (!element
|
|
5470
|
+
if (!element?.current)
|
|
5509
5471
|
return;
|
|
5510
5472
|
super.readKeyframes();
|
|
5511
5473
|
/**
|
|
@@ -5600,11 +5562,10 @@
|
|
|
5600
5562
|
}
|
|
5601
5563
|
measureInitialState() {
|
|
5602
5564
|
const { element, unresolvedKeyframes, name } = this;
|
|
5603
|
-
if (!element
|
|
5565
|
+
if (!element?.current)
|
|
5604
5566
|
return;
|
|
5605
|
-
if (name === "height")
|
|
5567
|
+
if (name === "height")
|
|
5606
5568
|
this.suspendedScrollY = window.pageYOffset;
|
|
5607
|
-
}
|
|
5608
5569
|
this.measuredOrigin = this.measure();
|
|
5609
5570
|
unresolvedKeyframes[0] = this.measuredOrigin;
|
|
5610
5571
|
// Set final key frame to measure after next render
|
|
@@ -5615,7 +5576,7 @@
|
|
|
5615
5576
|
}
|
|
5616
5577
|
measureEndState() {
|
|
5617
5578
|
const { element, unresolvedKeyframes } = this;
|
|
5618
|
-
if (!element
|
|
5579
|
+
if (!element?.current)
|
|
5619
5580
|
return;
|
|
5620
5581
|
this.motionValue?.jump(this.measuredOrigin, false);
|
|
5621
5582
|
const finalKeyframeIndex = unresolvedKeyframes.length - 1;
|
|
@@ -5624,14 +5585,6 @@
|
|
|
5624
5585
|
if (finalKeyframe !== null && this.finalKeyframe === undefined) {
|
|
5625
5586
|
this.finalKeyframe = finalKeyframe;
|
|
5626
5587
|
}
|
|
5627
|
-
// If we removed transform values, reapply them before the next render
|
|
5628
|
-
if (this.removedTransforms?.length) {
|
|
5629
|
-
this.removedTransforms.forEach(([unsetTransformName, unsetTransformValue]) => {
|
|
5630
|
-
element
|
|
5631
|
-
.getValue(unsetTransformName)
|
|
5632
|
-
.set(unsetTransformValue);
|
|
5633
|
-
});
|
|
5634
|
-
}
|
|
5635
5588
|
this.resolveNoneKeyframes();
|
|
5636
5589
|
}
|
|
5637
5590
|
}
|
|
@@ -5736,7 +5689,8 @@
|
|
|
5736
5689
|
*/
|
|
5737
5690
|
const effects = [];
|
|
5738
5691
|
function addEffect(effect) {
|
|
5739
|
-
motionUtils.invariant(typeof effect.test === "function" &&
|
|
5692
|
+
motionUtils.invariant(typeof effect.test === "function" &&
|
|
5693
|
+
typeof effect.read === "function", "Effects passed to animate.addEffect() need test() and read().", "effect-missing-test");
|
|
5740
5694
|
removeEffect(effect);
|
|
5741
5695
|
effects.unshift(effect);
|
|
5742
5696
|
}
|
|
@@ -6063,11 +6017,6 @@
|
|
|
6063
6017
|
});
|
|
6064
6018
|
}
|
|
6065
6019
|
|
|
6066
|
-
/**
|
|
6067
|
-
* Cache of `translateX(`-style openers so each render is a few string
|
|
6068
|
-
* concatenations rather than a template per transform.
|
|
6069
|
-
*/
|
|
6070
|
-
const openers = {};
|
|
6071
6020
|
function buildTransform(state) {
|
|
6072
6021
|
let transform = "";
|
|
6073
6022
|
const { transformKeys: keys = [], transformValues: values = {} } = state;
|
|
@@ -6080,14 +6029,8 @@
|
|
|
6080
6029
|
const value = values[key].getCurrent();
|
|
6081
6030
|
if (value === undefined)
|
|
6082
6031
|
continue;
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
transform +=
|
|
6086
|
-
(transform && " ") +
|
|
6087
|
-
(openers[key] ||
|
|
6088
|
-
(openers[key] = (translateAlias[key] || key) + "(")) +
|
|
6089
|
-
getValueAsType(value, transformValueTypes[key]) +
|
|
6090
|
-
")";
|
|
6032
|
+
if (!isDefaultTransform(key, value)) {
|
|
6033
|
+
transform += (transform && " ") + transformFunction(key, value);
|
|
6091
6034
|
}
|
|
6092
6035
|
}
|
|
6093
6036
|
// See build-transform.ts: additive `rotate()` so user `rotate` isn't
|
|
@@ -6095,10 +6038,7 @@
|
|
|
6095
6038
|
const pathRotation = state.get("pathRotation")?.get();
|
|
6096
6039
|
if (pathRotation) {
|
|
6097
6040
|
transform +=
|
|
6098
|
-
(transform && " ") +
|
|
6099
|
-
"rotate(" +
|
|
6100
|
-
getValueAsType(pathRotation, transformValueTypes.pathRotation) +
|
|
6101
|
-
")";
|
|
6041
|
+
(transform && " ") + transformFunction("rotate", pathRotation);
|
|
6102
6042
|
}
|
|
6103
6043
|
return transform || "none";
|
|
6104
6044
|
}
|
|
@@ -6501,10 +6441,24 @@
|
|
|
6501
6441
|
!isIdentityScale(scaleX) ||
|
|
6502
6442
|
!isIdentityScale(scaleY));
|
|
6503
6443
|
}
|
|
6444
|
+
/**
|
|
6445
|
+
* Rotations and skews, which projection can't correct for.
|
|
6446
|
+
*/
|
|
6447
|
+
const angleTransforms = [
|
|
6448
|
+
"rotate",
|
|
6449
|
+
"rotateX",
|
|
6450
|
+
"rotateY",
|
|
6451
|
+
"rotateZ",
|
|
6452
|
+
"skewX",
|
|
6453
|
+
"skewY",
|
|
6454
|
+
];
|
|
6504
6455
|
function hasTransform(values) {
|
|
6505
6456
|
return (hasScale(values) ||
|
|
6506
6457
|
has2DTranslate(values) ||
|
|
6507
|
-
values
|
|
6458
|
+
hasDistortingTransform(values));
|
|
6459
|
+
}
|
|
6460
|
+
function hasDistortingTransform(values) {
|
|
6461
|
+
return (values.z ||
|
|
6508
6462
|
values.rotate ||
|
|
6509
6463
|
values.rotateX ||
|
|
6510
6464
|
values.rotateY ||
|
|
@@ -6557,6 +6511,11 @@
|
|
|
6557
6511
|
* in a tree upon our box before then calculating how to project it into our desired viewport-relative box
|
|
6558
6512
|
*
|
|
6559
6513
|
* This is the final nested loop within updateLayoutDelta for future refactoring
|
|
6514
|
+
*
|
|
6515
|
+
* isSharedTransition is true for a shared layout animation in page space, which
|
|
6516
|
+
* also applies ancestor scroll and transforms. Or it's the layoutRoot a shared
|
|
6517
|
+
* animation is relative to, so only transforms of ancestors not shared with it
|
|
6518
|
+
* (or above it) are applied.
|
|
6560
6519
|
*/
|
|
6561
6520
|
function applyTreeDeltas(box, treeScale, treePath, isSharedTransition = false) {
|
|
6562
6521
|
const treeLength = treePath.length;
|
|
@@ -6573,13 +6532,10 @@
|
|
|
6573
6532
|
* TODO: Prefer to remove this, but currently we have motion components with
|
|
6574
6533
|
* display: contents in Framer.
|
|
6575
6534
|
*/
|
|
6576
|
-
|
|
6577
|
-
if (visualElement &&
|
|
6578
|
-
visualElement.props.style &&
|
|
6579
|
-
visualElement.props.style.display === "contents") {
|
|
6535
|
+
if (node.options.visualElement?.props.style?.display === "contents") {
|
|
6580
6536
|
continue;
|
|
6581
6537
|
}
|
|
6582
|
-
if (isSharedTransition &&
|
|
6538
|
+
if (isSharedTransition === true &&
|
|
6583
6539
|
node.options.layoutScroll &&
|
|
6584
6540
|
node.scroll &&
|
|
6585
6541
|
node !== node.root) {
|
|
@@ -6593,7 +6549,9 @@
|
|
|
6593
6549
|
// Apply each ancestor's calculated delta into this component's recorded layout box
|
|
6594
6550
|
applyBoxDelta(box, delta);
|
|
6595
6551
|
}
|
|
6596
|
-
if (isSharedTransition &&
|
|
6552
|
+
if (isSharedTransition &&
|
|
6553
|
+
(isSharedTransition.path?.[i] || isSharedTransition) !== node &&
|
|
6554
|
+
hasTransform(node.latestValues)) {
|
|
6597
6555
|
transformBox(box, node.latestValues, node.layout?.layoutBox);
|
|
6598
6556
|
}
|
|
6599
6557
|
}
|
|
@@ -6867,15 +6825,6 @@
|
|
|
6867
6825
|
const asNumber = (v) => typeof v === "number" ? v : parseFloat(v);
|
|
6868
6826
|
|
|
6869
6827
|
const numBorders = cornerRadiusProps.length;
|
|
6870
|
-
const mixedTransforms = [
|
|
6871
|
-
"rotate",
|
|
6872
|
-
"rotateX",
|
|
6873
|
-
"rotateY",
|
|
6874
|
-
"rotateZ",
|
|
6875
|
-
"skewX",
|
|
6876
|
-
"skewY",
|
|
6877
|
-
];
|
|
6878
|
-
const numMixedTransforms = mixedTransforms.length;
|
|
6879
6828
|
const isPx = (value) => typeof value === "number" || px.test(value);
|
|
6880
6829
|
function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnlyMember) {
|
|
6881
6830
|
if (shouldCrossfadeOpacity) {
|
|
@@ -6913,8 +6862,8 @@
|
|
|
6913
6862
|
* Mix rotation and skew. These can't be projected, so mix them every
|
|
6914
6863
|
* frame rather than leaving them frozen at the animation-start snapshot.
|
|
6915
6864
|
*/
|
|
6916
|
-
for (let i = 0; i <
|
|
6917
|
-
const key =
|
|
6865
|
+
for (let i = 0; i < angleTransforms.length; i++) {
|
|
6866
|
+
const key = angleTransforms[i];
|
|
6918
6867
|
if (follow[key] || lead[key]) {
|
|
6919
6868
|
target[key] = mixNumber$1(follow[key] || 0, lead[key] || 0, progress);
|
|
6920
6869
|
}
|
|
@@ -6997,8 +6946,8 @@
|
|
|
6997
6946
|
}
|
|
6998
6947
|
}
|
|
6999
6948
|
function calcBoxDelta(delta, source, target, origin) {
|
|
7000
|
-
calcAxisDelta(delta.x, source.x, target.x, origin
|
|
7001
|
-
calcAxisDelta(delta.y, source.y, target.y, origin
|
|
6949
|
+
calcAxisDelta(delta.x, source.x, target.x, origin?.originX);
|
|
6950
|
+
calcAxisDelta(delta.y, source.y, target.y, origin?.originY);
|
|
7002
6951
|
}
|
|
7003
6952
|
function calcRelativeAxis(target, relative, parent, anchor = 0) {
|
|
7004
6953
|
const anchorPoint = anchor
|
|
@@ -7068,8 +7017,8 @@
|
|
|
7068
7017
|
* and acts as a bridge between motion values and removeAxisDelta
|
|
7069
7018
|
*/
|
|
7070
7019
|
function removeBoxTransforms(box, transforms, originBox, sourceBox) {
|
|
7071
|
-
removeAxisTransforms(box.x, transforms, xKeys, originBox
|
|
7072
|
-
removeAxisTransforms(box.y, transforms, yKeys, originBox
|
|
7020
|
+
removeAxisTransforms(box.x, transforms, xKeys, originBox?.x, sourceBox?.x);
|
|
7021
|
+
removeAxisTransforms(box.y, transforms, yKeys, originBox?.y, sourceBox?.y);
|
|
7073
7022
|
}
|
|
7074
7023
|
|
|
7075
7024
|
const createAxisDelta = () => ({
|
|
@@ -7299,24 +7248,18 @@
|
|
|
7299
7248
|
transform += `scale(${1 / treeScale.x}, ${1 / treeScale.y}) `;
|
|
7300
7249
|
}
|
|
7301
7250
|
if (latestTransform) {
|
|
7302
|
-
const { transformPerspective
|
|
7251
|
+
const { transformPerspective } = latestTransform;
|
|
7303
7252
|
if (transformPerspective)
|
|
7304
7253
|
transform = `perspective(${transformPerspective}px) ${transform}`;
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
|
|
7313
|
-
|
|
7314
|
-
if (rotateZ)
|
|
7315
|
-
transform += `rotateZ(${rotateZ}deg) `;
|
|
7316
|
-
if (skewX)
|
|
7317
|
-
transform += `skewX(${skewX}deg) `;
|
|
7318
|
-
if (skewY)
|
|
7319
|
-
transform += `skewY(${skewY}deg) `;
|
|
7254
|
+
for (let i = 0; i < angleTransforms.length; i++) {
|
|
7255
|
+
const key = angleTransforms[i];
|
|
7256
|
+
const value = latestTransform[key];
|
|
7257
|
+
if (value)
|
|
7258
|
+
transform += `${key}(${value}deg) `;
|
|
7259
|
+
// Additive `rotate()` so user `rotate` isn't clobbered.
|
|
7260
|
+
if (!i && latestTransform.pathRotation)
|
|
7261
|
+
transform += `rotate(${latestTransform.pathRotation}deg) `;
|
|
7262
|
+
}
|
|
7320
7263
|
}
|
|
7321
7264
|
/**
|
|
7322
7265
|
* Apply scale to match the size of the element to the size we want it.
|
|
@@ -7379,7 +7322,10 @@
|
|
|
7379
7322
|
calculatedTargetDeltas: 0,
|
|
7380
7323
|
calculatedProjections: 0,
|
|
7381
7324
|
};
|
|
7382
|
-
|
|
7325
|
+
/**
|
|
7326
|
+
* Transforms that distort an element's layout, so must be reset before measuring.
|
|
7327
|
+
*/
|
|
7328
|
+
const distortingTransforms = ["z", "skew", "skewZ"];
|
|
7383
7329
|
/**
|
|
7384
7330
|
* We use 1000 as the animation target as 0-1000 maps better to pixels than 0-1
|
|
7385
7331
|
* which has a noticeable difference in spring animations
|
|
@@ -7397,7 +7343,15 @@
|
|
|
7397
7343
|
}
|
|
7398
7344
|
}
|
|
7399
7345
|
}
|
|
7400
|
-
|
|
7346
|
+
/**
|
|
7347
|
+
* Move accelerated transforms back to the main thread. The WAAPI animation
|
|
7348
|
+
* hid startUpdate()'s reset of rotations, skews and z, and moving off it
|
|
7349
|
+
* writes the whole transform back, so reset them again before this node
|
|
7350
|
+
* is measured.
|
|
7351
|
+
*/
|
|
7352
|
+
const demoteTransforms = (node) => node.instance &&
|
|
7353
|
+
transformGroups.get(node.instance)?.demote() &&
|
|
7354
|
+
node.resetSkewAndRotation();
|
|
7401
7355
|
function cancelTreeOptimisedTransformAnimations(projectionNode) {
|
|
7402
7356
|
projectionNode.hasCheckedOptimisedAppear = true;
|
|
7403
7357
|
if (projectionNode.root === projectionNode)
|
|
@@ -7587,8 +7541,7 @@
|
|
|
7587
7541
|
return this.eventHandlers.get(name).add(handler);
|
|
7588
7542
|
}
|
|
7589
7543
|
notifyListeners(name, ...args) {
|
|
7590
|
-
|
|
7591
|
-
subscriptionManager && subscriptionManager.notify(...args);
|
|
7544
|
+
this.eventHandlers.get(name)?.notify(...args);
|
|
7592
7545
|
}
|
|
7593
7546
|
hasListeners(name) {
|
|
7594
7547
|
return this.eventHandlers.has(name);
|
|
@@ -7606,7 +7559,7 @@
|
|
|
7606
7559
|
visualElement.mount(instance);
|
|
7607
7560
|
}
|
|
7608
7561
|
this.root.nodes.add(this);
|
|
7609
|
-
this.parent
|
|
7562
|
+
this.parent?.children.add(this);
|
|
7610
7563
|
if (this.root.hasTreeAnimated && (layout || layoutId)) {
|
|
7611
7564
|
this.isLayoutDirty = true;
|
|
7612
7565
|
}
|
|
@@ -7624,7 +7577,7 @@
|
|
|
7624
7577
|
return;
|
|
7625
7578
|
innerWidth = newInnerWidth;
|
|
7626
7579
|
this.root.updateBlockedByResize = true;
|
|
7627
|
-
cancelDelay
|
|
7580
|
+
cancelDelay?.();
|
|
7628
7581
|
cancelDelay = delay(resizeUnblockUpdate, 250);
|
|
7629
7582
|
if (globalProjectionState.hasAnimatedSinceResize) {
|
|
7630
7583
|
globalProjectionState.hasAnimatedSinceResize = false;
|
|
@@ -7715,9 +7668,7 @@
|
|
|
7715
7668
|
if (!hasLayoutChanged) {
|
|
7716
7669
|
finishAnimation(this);
|
|
7717
7670
|
}
|
|
7718
|
-
|
|
7719
|
-
this.options.onExitComplete();
|
|
7720
|
-
}
|
|
7671
|
+
this.isLead() && this.options.onExitComplete?.();
|
|
7721
7672
|
}
|
|
7722
7673
|
this.targetLayout = newLayout;
|
|
7723
7674
|
});
|
|
@@ -7725,9 +7676,8 @@
|
|
|
7725
7676
|
unmount() {
|
|
7726
7677
|
this.options.layoutId && this.willUpdate();
|
|
7727
7678
|
this.root.nodes.remove(this);
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
this.parent && this.parent.children.delete(this);
|
|
7679
|
+
this.getStack()?.remove(this);
|
|
7680
|
+
this.parent?.children.delete(this);
|
|
7731
7681
|
this.instance = undefined;
|
|
7732
7682
|
this.eventHandlers.clear();
|
|
7733
7683
|
this.hasLayoutListener = false;
|
|
@@ -7748,7 +7698,7 @@
|
|
|
7748
7698
|
if (this.isUpdateBlocked())
|
|
7749
7699
|
return;
|
|
7750
7700
|
this.isUpdating = true;
|
|
7751
|
-
this.nodes
|
|
7701
|
+
this.nodes?.forEach(resetSkewAndRotation);
|
|
7752
7702
|
this.animationId++;
|
|
7753
7703
|
}
|
|
7754
7704
|
getTransformTemplate() {
|
|
@@ -7758,7 +7708,7 @@
|
|
|
7758
7708
|
willUpdate(shouldNotifyListeners = true) {
|
|
7759
7709
|
this.root.hasTreeAnimated = true;
|
|
7760
7710
|
if (this.root.isUpdateBlocked()) {
|
|
7761
|
-
this.options.onExitComplete
|
|
7711
|
+
this.options.onExitComplete?.();
|
|
7762
7712
|
return;
|
|
7763
7713
|
}
|
|
7764
7714
|
/**
|
|
@@ -7975,24 +7925,23 @@
|
|
|
7975
7925
|
this.projectionDelta = undefined;
|
|
7976
7926
|
this.notifyListeners("measure", this.layout.layoutBox);
|
|
7977
7927
|
const { visualElement } = this.options;
|
|
7978
|
-
visualElement
|
|
7979
|
-
visualElement.notify("LayoutMeasure", this.layout.layoutBox, prevLayout ? prevLayout.layoutBox : undefined);
|
|
7928
|
+
visualElement?.notify("LayoutMeasure", this.layout.layoutBox, prevLayout?.layoutBox);
|
|
7980
7929
|
}
|
|
7981
7930
|
updateScroll(phase = "measure") {
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
const isRoot = checkIsScrollRoot(
|
|
7931
|
+
const { scroll, instance } = this;
|
|
7932
|
+
const { animationId } = this.root;
|
|
7933
|
+
if (this.options.layoutScroll &&
|
|
7934
|
+
instance &&
|
|
7935
|
+
!(scroll &&
|
|
7936
|
+
scroll.animationId === animationId &&
|
|
7937
|
+
scroll.phase === phase)) {
|
|
7938
|
+
const isRoot = checkIsScrollRoot(instance);
|
|
7990
7939
|
this.scroll = {
|
|
7991
|
-
animationId
|
|
7940
|
+
animationId,
|
|
7992
7941
|
phase,
|
|
7993
7942
|
isRoot,
|
|
7994
|
-
offset: measureScroll(
|
|
7995
|
-
wasRoot:
|
|
7943
|
+
offset: measureScroll(instance),
|
|
7944
|
+
wasRoot: scroll ? scroll.isRoot : isRoot,
|
|
7996
7945
|
};
|
|
7997
7946
|
}
|
|
7998
7947
|
}
|
|
@@ -8082,10 +8031,10 @@
|
|
|
8082
8031
|
}
|
|
8083
8032
|
return boxWithoutScroll;
|
|
8084
8033
|
}
|
|
8085
|
-
applyTransform(box, transformOnly = false, output, skipOwnTransform) {
|
|
8034
|
+
applyTransform(box, transformOnly = false, output, skipOwnTransform, start = 0) {
|
|
8086
8035
|
const withTransforms = output || createBox();
|
|
8087
8036
|
copyBoxInto(withTransforms, box);
|
|
8088
|
-
for (let i =
|
|
8037
|
+
for (let i = start; i < this.path.length; i++) {
|
|
8089
8038
|
const node = this.path[i];
|
|
8090
8039
|
if (!transformOnly &&
|
|
8091
8040
|
node.options.layoutScroll &&
|
|
@@ -8257,8 +8206,13 @@
|
|
|
8257
8206
|
this.attemptToResolveRelativeTarget = false;
|
|
8258
8207
|
if (this.options.layoutAnchor !== false &&
|
|
8259
8208
|
relativeParent &&
|
|
8260
|
-
|
|
8261
|
-
|
|
8209
|
+
(!relativeParent.resumingFrom === !this.resumingFrom ||
|
|
8210
|
+
/**
|
|
8211
|
+
* Shared layout animations within a layoutRoot
|
|
8212
|
+
* animate relative to it.
|
|
8213
|
+
*/
|
|
8214
|
+
(relativeParent.options.layoutRoot &&
|
|
8215
|
+
!relativeParent.resumingFrom)) &&
|
|
8262
8216
|
!relativeParent.options.layoutScroll &&
|
|
8263
8217
|
relativeParent.target &&
|
|
8264
8218
|
this.animationProgress !== 1) {
|
|
@@ -8338,7 +8292,7 @@
|
|
|
8338
8292
|
* If this section of the tree isn't animating we can
|
|
8339
8293
|
* delete our target sources for the following frame.
|
|
8340
8294
|
*/
|
|
8341
|
-
this.isTreeAnimating = Boolean(
|
|
8295
|
+
this.isTreeAnimating = Boolean(this.parent?.isTreeAnimating ||
|
|
8342
8296
|
this.currentAnimation ||
|
|
8343
8297
|
this.pendingAnimation);
|
|
8344
8298
|
if (!this.isTreeAnimating) {
|
|
@@ -8359,8 +8313,17 @@
|
|
|
8359
8313
|
/**
|
|
8360
8314
|
* Apply all the parent deltas to this box to produce the corrected box. This
|
|
8361
8315
|
* is the layout box, as it will appear on screen as a result of the transforms of its parents.
|
|
8316
|
+
*
|
|
8317
|
+
* A shared target is usually in page space, so ancestor transforms are applied
|
|
8318
|
+
* too. But a target relative to a parent that isn't itself shared (like a
|
|
8319
|
+
* layoutRoot) is in that parent's layout space. So the transforms of the
|
|
8320
|
+
* parent and its ancestors, which move both elements alike, are skipped,
|
|
8321
|
+
* but those of other ancestors (between it and either element) apply.
|
|
8362
8322
|
*/
|
|
8363
|
-
applyTreeDeltas(this.layoutCorrected, this.treeScale, this.path, isShared
|
|
8323
|
+
applyTreeDeltas(this.layoutCorrected, this.treeScale, this.path, isShared &&
|
|
8324
|
+
(lead.relativeTarget && !lead.relativeParent.resumingFrom
|
|
8325
|
+
? lead.relativeParent
|
|
8326
|
+
: true));
|
|
8364
8327
|
/**
|
|
8365
8328
|
* If this layer needs to perform scale correction but doesn't have a target,
|
|
8366
8329
|
* use the layout as the target.
|
|
@@ -8427,8 +8390,7 @@
|
|
|
8427
8390
|
scheduleRender(notifyAll = true) {
|
|
8428
8391
|
this.options.visualElement?.scheduleRender();
|
|
8429
8392
|
if (notifyAll) {
|
|
8430
|
-
|
|
8431
|
-
stack && stack.scheduleRender();
|
|
8393
|
+
this.getStack()?.scheduleRender();
|
|
8432
8394
|
}
|
|
8433
8395
|
if (this.resumingFrom && !this.resumingFrom.instance) {
|
|
8434
8396
|
this.resumingFrom = undefined;
|
|
@@ -8450,9 +8412,7 @@
|
|
|
8450
8412
|
}
|
|
8451
8413
|
this.attemptToResolveRelativeTarget = !hasOnlyRelativeTargetChanged;
|
|
8452
8414
|
const relativeLayout = createBox();
|
|
8453
|
-
const
|
|
8454
|
-
const layoutSource = this.layout ? this.layout.source : undefined;
|
|
8455
|
-
const isSharedLayoutAnimation = snapshotSource !== layoutSource;
|
|
8415
|
+
const isSharedLayoutAnimation = snapshot?.source !== this.layout?.source;
|
|
8456
8416
|
const stack = this.getStack();
|
|
8457
8417
|
const isOnlyMember = !stack || stack.members.length <= 1;
|
|
8458
8418
|
const shouldCrossfadeOpacity = Boolean(isSharedLayoutAnimation &&
|
|
@@ -8467,19 +8427,11 @@
|
|
|
8467
8427
|
this.mixTargetDelta = (latest) => {
|
|
8468
8428
|
const progress = latest / 1000;
|
|
8469
8429
|
const point = interpolate?.(progress);
|
|
8430
|
+
mixAxisDeltaLinear(targetDelta.x, delta.x, progress);
|
|
8431
|
+
mixAxisDeltaLinear(targetDelta.y, delta.y, progress);
|
|
8470
8432
|
if (point) {
|
|
8471
8433
|
targetDelta.x.translate = point.x;
|
|
8472
|
-
targetDelta.x.scale = mixNumber$1(delta.x.scale, 1, progress);
|
|
8473
|
-
targetDelta.x.origin = delta.x.origin;
|
|
8474
|
-
targetDelta.x.originPoint = delta.x.originPoint;
|
|
8475
8434
|
targetDelta.y.translate = point.y;
|
|
8476
|
-
targetDelta.y.scale = mixNumber$1(delta.y.scale, 1, progress);
|
|
8477
|
-
targetDelta.y.origin = delta.y.origin;
|
|
8478
|
-
targetDelta.y.originPoint = delta.y.originPoint;
|
|
8479
|
-
}
|
|
8480
|
-
else {
|
|
8481
|
-
mixAxisDeltaLinear(targetDelta.x, delta.x, progress);
|
|
8482
|
-
mixAxisDeltaLinear(targetDelta.y, delta.y, progress);
|
|
8483
8435
|
}
|
|
8484
8436
|
this.setTargetDelta(targetDelta);
|
|
8485
8437
|
if (this.relativeTarget &&
|
|
@@ -8505,7 +8457,7 @@
|
|
|
8505
8457
|
this.animationValues = mixedValues;
|
|
8506
8458
|
mixValues(mixedValues, snapshotLatestValues, this.latestValues, progress, shouldCrossfadeOpacity, isOnlyMember);
|
|
8507
8459
|
}
|
|
8508
|
-
if (point
|
|
8460
|
+
if (point?.rotate !== undefined) {
|
|
8509
8461
|
// Dedicated `pathRotation` channel, not `rotate`, so an
|
|
8510
8462
|
// animating `rotate` is composed with, never clobbered.
|
|
8511
8463
|
if (!this.animationValues)
|
|
@@ -8570,7 +8522,7 @@
|
|
|
8570
8522
|
}
|
|
8571
8523
|
finishAnimation() {
|
|
8572
8524
|
if (this.currentAnimation) {
|
|
8573
|
-
this.mixTargetDelta
|
|
8525
|
+
this.mixTargetDelta?.(animationTarget);
|
|
8574
8526
|
this.currentAnimation.stop();
|
|
8575
8527
|
}
|
|
8576
8528
|
this.completeAnimation();
|
|
@@ -8590,13 +8542,11 @@
|
|
|
8590
8542
|
this.layout &&
|
|
8591
8543
|
layout &&
|
|
8592
8544
|
shouldAnimatePositionOnly(this.options.animationType, this.layout.layoutBox, layout.layoutBox)) {
|
|
8545
|
+
const { layoutBox } = this.layout;
|
|
8546
|
+
const leadTarget = target;
|
|
8593
8547
|
target = this.target || createBox();
|
|
8594
|
-
|
|
8595
|
-
target.
|
|
8596
|
-
target.x.max = target.x.min + xLength;
|
|
8597
|
-
const yLength = calcLength(this.layout.layoutBox.y);
|
|
8598
|
-
target.y.min = lead.target.y.min;
|
|
8599
|
-
target.y.max = target.y.min + yLength;
|
|
8548
|
+
alignAxis(target.x, leadTarget.x, layoutBox.x);
|
|
8549
|
+
alignAxis(target.y, leadTarget.y, layoutBox.y);
|
|
8600
8550
|
}
|
|
8601
8551
|
copyBoxInto(targetWithTransforms, target);
|
|
8602
8552
|
/**
|
|
@@ -8621,8 +8571,8 @@
|
|
|
8621
8571
|
stack.add(node);
|
|
8622
8572
|
const config = node.options.initialPromotionConfig;
|
|
8623
8573
|
node.promote({
|
|
8624
|
-
transition: config
|
|
8625
|
-
preserveFollowOpacity: config
|
|
8574
|
+
transition: config?.transition,
|
|
8575
|
+
preserveFollowOpacity: config?.shouldPreserveFollowOpacity
|
|
8626
8576
|
? config.shouldPreserveFollowOpacity(node)
|
|
8627
8577
|
: undefined,
|
|
8628
8578
|
});
|
|
@@ -8645,9 +8595,7 @@
|
|
|
8645
8595
|
return this.root.sharedNodes.get(layoutId);
|
|
8646
8596
|
}
|
|
8647
8597
|
promote({ needsReset, transition, preserveFollowOpacity, } = {}) {
|
|
8648
|
-
|
|
8649
|
-
if (stack)
|
|
8650
|
-
stack.promote(this, preserveFollowOpacity);
|
|
8598
|
+
this.getStack()?.promote(this, preserveFollowOpacity);
|
|
8651
8599
|
if (needsReset) {
|
|
8652
8600
|
this.projectionDelta = undefined;
|
|
8653
8601
|
this.needsReset = true;
|
|
@@ -8656,45 +8604,27 @@
|
|
|
8656
8604
|
this.setOptions({ transition });
|
|
8657
8605
|
}
|
|
8658
8606
|
relegate() {
|
|
8659
|
-
|
|
8660
|
-
if (stack) {
|
|
8661
|
-
return stack.relegate(this);
|
|
8662
|
-
}
|
|
8663
|
-
else {
|
|
8664
|
-
return false;
|
|
8665
|
-
}
|
|
8607
|
+
return this.getStack()?.relegate(this) || false;
|
|
8666
8608
|
}
|
|
8667
8609
|
resetSkewAndRotation() {
|
|
8668
8610
|
const { visualElement } = this.options;
|
|
8669
8611
|
if (!visualElement)
|
|
8670
8612
|
return;
|
|
8671
|
-
// If there's no detected skew or rotation values, we can early return without a forced render.
|
|
8672
|
-
let hasDistortingTransform = false;
|
|
8673
8613
|
/**
|
|
8674
8614
|
* An unrolled check for rotation values. Most elements don't have any rotation and
|
|
8675
|
-
* skipping the
|
|
8615
|
+
* skipping the loop and new object creation is 50% faster.
|
|
8616
|
+
* If there's no distorting values, we don't need to do any more.
|
|
8676
8617
|
*/
|
|
8677
8618
|
const { latestValues } = visualElement;
|
|
8678
|
-
if (latestValues
|
|
8679
|
-
latestValues.rotate ||
|
|
8680
|
-
latestValues.rotateX ||
|
|
8681
|
-
latestValues.rotateY ||
|
|
8682
|
-
latestValues.rotateZ ||
|
|
8683
|
-
latestValues.skewX ||
|
|
8684
|
-
latestValues.skewY) {
|
|
8685
|
-
hasDistortingTransform = true;
|
|
8686
|
-
}
|
|
8687
|
-
// If there's no distorting values, we don't need to do any more.
|
|
8688
|
-
if (!hasDistortingTransform)
|
|
8619
|
+
if (!hasDistortingTransform(latestValues))
|
|
8689
8620
|
return;
|
|
8690
8621
|
const resetValues = {};
|
|
8691
|
-
if (latestValues.z) {
|
|
8692
|
-
resetDistortingTransform("z", visualElement, resetValues, this.animationValues);
|
|
8693
|
-
}
|
|
8694
8622
|
// Check the skew and rotate value of all axes and reset to 0
|
|
8695
|
-
for (let i = 0; i <
|
|
8696
|
-
resetDistortingTransform(
|
|
8697
|
-
|
|
8623
|
+
for (let i = 0; i < distortingTransforms.length; i++) {
|
|
8624
|
+
resetDistortingTransform(distortingTransforms[i], visualElement, resetValues, this.animationValues);
|
|
8625
|
+
}
|
|
8626
|
+
for (let i = 0; i < angleTransforms.length; i++) {
|
|
8627
|
+
resetDistortingTransform(angleTransforms[i], visualElement, resetValues, this.animationValues);
|
|
8698
8628
|
}
|
|
8699
8629
|
// Force a render of this element to apply the transform with all skews and rotations
|
|
8700
8630
|
// set to 0.
|
|
@@ -8714,7 +8644,13 @@
|
|
|
8714
8644
|
styleProp) {
|
|
8715
8645
|
if (!this.instance || this.isSVG)
|
|
8716
8646
|
return;
|
|
8717
|
-
|
|
8647
|
+
const lead = this.getLead();
|
|
8648
|
+
/**
|
|
8649
|
+
* Without crossfade, a new lead hides the previous one, as it's
|
|
8650
|
+
* usually unmounting. One that gave its layoutId away keeps
|
|
8651
|
+
* rendering, so only hide nodes that follow another.
|
|
8652
|
+
*/
|
|
8653
|
+
if (!this.isVisible && lead !== this) {
|
|
8718
8654
|
targetStyle.visibility = "hidden";
|
|
8719
8655
|
return;
|
|
8720
8656
|
}
|
|
@@ -8730,9 +8666,10 @@
|
|
|
8730
8666
|
: "none";
|
|
8731
8667
|
return;
|
|
8732
8668
|
}
|
|
8733
|
-
const lead = this.getLead();
|
|
8734
8669
|
if (!this.projectionDelta || !this.layout || !lead.target) {
|
|
8735
|
-
if (this.options.layoutId) {
|
|
8670
|
+
if (this.options.layoutId || this.needsShow) {
|
|
8671
|
+
this.needsShow = false;
|
|
8672
|
+
targetStyle.visibility = "";
|
|
8736
8673
|
targetStyle.opacity =
|
|
8737
8674
|
this.latestValues.opacity !== undefined
|
|
8738
8675
|
? this.latestValues.opacity
|
|
@@ -8866,52 +8803,49 @@
|
|
|
8866
8803
|
const isShared = snapshot.source !== node.layout.source;
|
|
8867
8804
|
// TODO Maybe we want to also resize the layout snapshot so we don't trigger
|
|
8868
8805
|
// animations for instance if layout="size" and an element has only changed position
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
8873
|
-
|
|
8874
|
-
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
|
|
8885
|
-
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
|
|
8889
|
-
|
|
8890
|
-
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
|
|
8895
|
-
|
|
8896
|
-
|
|
8897
|
-
|
|
8898
|
-
node.relativeTarget[axis].min + length;
|
|
8899
|
-
}
|
|
8900
|
-
});
|
|
8901
|
-
}
|
|
8806
|
+
const resizeSnapshot = (box, to) => {
|
|
8807
|
+
if (animationType === "size") {
|
|
8808
|
+
eachAxis((axis) => {
|
|
8809
|
+
const length = calcLength(box[axis]);
|
|
8810
|
+
box[axis].min = to[axis].min;
|
|
8811
|
+
box[axis].max = box[axis].min + length;
|
|
8812
|
+
});
|
|
8813
|
+
}
|
|
8814
|
+
else if (animationType === "x" || animationType === "y") {
|
|
8815
|
+
const snapAxis = animationType === "x" ? "y" : "x";
|
|
8816
|
+
copyAxisInto(box[snapAxis], to[snapAxis]);
|
|
8817
|
+
}
|
|
8818
|
+
else if (shouldAnimatePositionOnly(animationType, snapshot.layoutBox, layout)) {
|
|
8819
|
+
eachAxis((axis) => {
|
|
8820
|
+
const length = calcLength(to[axis]);
|
|
8821
|
+
box[axis].max = box[axis].min + length;
|
|
8822
|
+
/**
|
|
8823
|
+
* Ensure relative target gets resized and rerendererd
|
|
8824
|
+
*/
|
|
8825
|
+
if (node.relativeTarget && !node.currentAnimation) {
|
|
8826
|
+
node.isProjectionDirty = true;
|
|
8827
|
+
node.relativeTarget[axis].max =
|
|
8828
|
+
node.relativeTarget[axis].min + length;
|
|
8829
|
+
}
|
|
8830
|
+
});
|
|
8831
|
+
}
|
|
8832
|
+
};
|
|
8833
|
+
const snapshotBox = isShared ? snapshot.measuredBox : snapshot.layoutBox;
|
|
8834
|
+
resizeSnapshot(snapshotBox, layout);
|
|
8902
8835
|
const layoutDelta = createDelta();
|
|
8903
8836
|
calcBoxDelta(layoutDelta, layout, snapshot.layoutBox);
|
|
8904
8837
|
const visualDelta = createDelta();
|
|
8905
|
-
|
|
8906
|
-
calcBoxDelta(visualDelta, node.applyTransform(measuredLayout, true), snapshot.measuredBox);
|
|
8907
|
-
}
|
|
8908
|
-
else {
|
|
8909
|
-
calcBoxDelta(visualDelta, layout, snapshot.layoutBox);
|
|
8910
|
-
}
|
|
8838
|
+
calcBoxDelta(visualDelta, isShared ? node.applyTransform(measuredLayout, true) : layout, snapshotBox);
|
|
8911
8839
|
const hasLayoutChanged = !isDeltaZero(layoutDelta);
|
|
8912
8840
|
let hasRelativeLayoutChanged = false;
|
|
8913
|
-
|
|
8914
|
-
|
|
8841
|
+
const relativeParent = node.getClosestProjectingParent();
|
|
8842
|
+
/**
|
|
8843
|
+
* A snapshot resumed from another element is only relative to this
|
|
8844
|
+
* node's relativeParent if it's a layoutRoot that contains both.
|
|
8845
|
+
*/
|
|
8846
|
+
if (!node.resumeFrom ||
|
|
8847
|
+
(relativeParent?.options.layoutRoot &&
|
|
8848
|
+
node.resumeFrom.path.includes(relativeParent))) {
|
|
8915
8849
|
/**
|
|
8916
8850
|
* If the relativeParent is itself resuming from a different element then
|
|
8917
8851
|
* the relative snapshot is not relavent
|
|
@@ -8920,10 +8854,22 @@
|
|
|
8920
8854
|
const { snapshot: parentSnapshot, layout: parentLayout } = relativeParent;
|
|
8921
8855
|
if (parentSnapshot && parentLayout) {
|
|
8922
8856
|
const anchor = node.options.layoutAnchor || undefined;
|
|
8857
|
+
/**
|
|
8858
|
+
* A shared snapshot includes the transforms of the old
|
|
8859
|
+
* element's ancestors below the layoutRoot, as they
|
|
8860
|
+
* aren't shared with the new element.
|
|
8861
|
+
*/
|
|
8923
8862
|
const relativeSnapshot = createBox();
|
|
8924
|
-
calcRelativePosition(relativeSnapshot,
|
|
8863
|
+
calcRelativePosition(relativeSnapshot, isShared
|
|
8864
|
+
? node.resumeFrom.applyTransform(snapshot.layoutBox, true, undefined, true, relativeParent.depth + 1)
|
|
8865
|
+
: snapshot.layoutBox, parentSnapshot.layoutBox, anchor);
|
|
8925
8866
|
const relativeLayout = createBox();
|
|
8926
8867
|
calcRelativePosition(relativeLayout, layout, parentLayout.layoutBox, anchor);
|
|
8868
|
+
/**
|
|
8869
|
+
* A shared snapshot is resized in page space, above, so
|
|
8870
|
+
* resize it relative to the layoutRoot too.
|
|
8871
|
+
*/
|
|
8872
|
+
isShared && resizeSnapshot(relativeSnapshot, relativeLayout);
|
|
8927
8873
|
if (!boxEqualsRounded(relativeSnapshot, relativeLayout)) {
|
|
8928
8874
|
hasRelativeLayoutChanged = true;
|
|
8929
8875
|
}
|
|
@@ -8945,8 +8891,7 @@
|
|
|
8945
8891
|
});
|
|
8946
8892
|
}
|
|
8947
8893
|
else if (node.isLead()) {
|
|
8948
|
-
|
|
8949
|
-
onExitComplete && onExitComplete();
|
|
8894
|
+
node.options.onExitComplete?.();
|
|
8950
8895
|
}
|
|
8951
8896
|
/**
|
|
8952
8897
|
* Clearing transition
|
|
@@ -9052,7 +8997,7 @@
|
|
|
9052
8997
|
}
|
|
9053
8998
|
function resetTransformStyle(node) {
|
|
9054
8999
|
const { visualElement } = node.options;
|
|
9055
|
-
if (visualElement
|
|
9000
|
+
if (visualElement?.getProps().onBeforeLayoutMeasure) {
|
|
9056
9001
|
visualElement.notify("BeforeLayoutMeasure");
|
|
9057
9002
|
}
|
|
9058
9003
|
node.resetTransform();
|
|
@@ -9086,7 +9031,7 @@
|
|
|
9086
9031
|
mixAxis(output.y, from.y, to.y, p);
|
|
9087
9032
|
}
|
|
9088
9033
|
function hasOpacityCrossfade(node) {
|
|
9089
|
-
return
|
|
9034
|
+
return node.animationValues?.opacityExit !== undefined;
|
|
9090
9035
|
}
|
|
9091
9036
|
const defaultLayoutTransition = {
|
|
9092
9037
|
duration: 0.45,
|
|
@@ -9112,6 +9057,13 @@
|
|
|
9112
9057
|
roundAxis(box.x);
|
|
9113
9058
|
roundAxis(box.y);
|
|
9114
9059
|
}
|
|
9060
|
+
/**
|
|
9061
|
+
* Align an axis to the start of another, keeping the length of a layout axis.
|
|
9062
|
+
* The length is read first, as output can be the layout axis itself.
|
|
9063
|
+
*/
|
|
9064
|
+
function alignAxis(output, from, layout) {
|
|
9065
|
+
output.max = calcLength(layout) + (output.min = from.min);
|
|
9066
|
+
}
|
|
9115
9067
|
function shouldAnimatePositionOnly(animationType, snapshot, layout) {
|
|
9116
9068
|
return (animationType === "position" ||
|
|
9117
9069
|
(animationType === "preserve-aspect" &&
|
|
@@ -9162,7 +9114,7 @@
|
|
|
9162
9114
|
resetTransform: (instance, value) => {
|
|
9163
9115
|
instance.style.transform = value !== undefined ? value : "none";
|
|
9164
9116
|
},
|
|
9165
|
-
checkIsScrollRoot: (instance) =>
|
|
9117
|
+
checkIsScrollRoot: (instance) => window.getComputedStyle(instance).position === "fixed",
|
|
9166
9118
|
});
|
|
9167
9119
|
|
|
9168
9120
|
const visualElementStore = new WeakMap();
|
|
@@ -9448,9 +9400,7 @@
|
|
|
9448
9400
|
}
|
|
9449
9401
|
this.current = instance;
|
|
9450
9402
|
visualElementStore.set(instance, this);
|
|
9451
|
-
|
|
9452
|
-
this.projection.mount(instance);
|
|
9453
|
-
}
|
|
9403
|
+
this.projection?.instance || this.projection?.mount(instance);
|
|
9454
9404
|
/**
|
|
9455
9405
|
* Join the closest variant node above, so its variant changes
|
|
9456
9406
|
* propagate here, unless inherit={false} cuts the chain.
|
|
@@ -9496,12 +9446,12 @@
|
|
|
9496
9446
|
this.hasBeenMounted = true;
|
|
9497
9447
|
}
|
|
9498
9448
|
unmount() {
|
|
9499
|
-
this.projection
|
|
9449
|
+
this.projection?.unmount();
|
|
9500
9450
|
cancelFrame(this.notifyUpdate);
|
|
9501
9451
|
cancelFrame(this.render);
|
|
9502
9452
|
this.valueSubscriptions.forEach((remove) => remove());
|
|
9503
9453
|
this.valueSubscriptions.clear();
|
|
9504
|
-
this.removeFromVariantTree
|
|
9454
|
+
this.removeFromVariantTree?.();
|
|
9505
9455
|
this.parent?.removeChild(this);
|
|
9506
9456
|
for (const key in this.events) {
|
|
9507
9457
|
this.events[key].clear();
|
|
@@ -9517,17 +9467,14 @@
|
|
|
9517
9467
|
}
|
|
9518
9468
|
addChild(child) {
|
|
9519
9469
|
this.children.add(child);
|
|
9520
|
-
this.enteringChildren
|
|
9521
|
-
this.enteringChildren.add(child);
|
|
9470
|
+
(this.enteringChildren || (this.enteringChildren = new Set())).add(child);
|
|
9522
9471
|
}
|
|
9523
9472
|
removeChild(child) {
|
|
9524
9473
|
this.children.delete(child);
|
|
9525
|
-
this.enteringChildren
|
|
9474
|
+
this.enteringChildren?.delete(child);
|
|
9526
9475
|
}
|
|
9527
9476
|
bindToMotionValue(key, value) {
|
|
9528
|
-
|
|
9529
|
-
this.valueSubscriptions.get(key)();
|
|
9530
|
-
}
|
|
9477
|
+
this.valueSubscriptions.get(key)?.();
|
|
9531
9478
|
if (value.accelerate &&
|
|
9532
9479
|
acceleratedValues.has(key) &&
|
|
9533
9480
|
this.current instanceof HTMLElement) {
|
|
@@ -9569,8 +9516,7 @@
|
|
|
9569
9516
|
}
|
|
9570
9517
|
this.valueSubscriptions.set(key, () => {
|
|
9571
9518
|
removeOnChange();
|
|
9572
|
-
|
|
9573
|
-
removeSyncCheck();
|
|
9519
|
+
removeSyncCheck?.();
|
|
9574
9520
|
// Defer to MotionValue.on("change") auto-stop so React 19 remounts
|
|
9575
9521
|
// can resubscribe before the animation is cancelled (#3315).
|
|
9576
9522
|
});
|
|
@@ -9663,10 +9609,8 @@
|
|
|
9663
9609
|
*/
|
|
9664
9610
|
for (let i = 0; i < propEventHandlers.length; i++) {
|
|
9665
9611
|
const key = propEventHandlers[i];
|
|
9666
|
-
|
|
9667
|
-
|
|
9668
|
-
delete this.propEventSubscriptions[key];
|
|
9669
|
-
}
|
|
9612
|
+
this.propEventSubscriptions[key]?.();
|
|
9613
|
+
delete this.propEventSubscriptions[key];
|
|
9670
9614
|
const listenerName = ("on" + key);
|
|
9671
9615
|
const listener = props[listenerName];
|
|
9672
9616
|
if (listener) {
|
|
@@ -9674,9 +9618,7 @@
|
|
|
9674
9618
|
}
|
|
9675
9619
|
}
|
|
9676
9620
|
this.prevMotionValues = updateMotionValuesFromProps(this, this.scrapeMotionValuesFromProps(props, this.prevProps || {}, this), this.prevMotionValues);
|
|
9677
|
-
|
|
9678
|
-
this.handleChildMotionValue();
|
|
9679
|
-
}
|
|
9621
|
+
this.handleChildMotionValue?.();
|
|
9680
9622
|
}
|
|
9681
9623
|
getProps() {
|
|
9682
9624
|
return this.props;
|
|
@@ -9685,7 +9627,7 @@
|
|
|
9685
9627
|
* Returns the variant definition with a given name.
|
|
9686
9628
|
*/
|
|
9687
9629
|
getVariant(name) {
|
|
9688
|
-
return this.props.variants
|
|
9630
|
+
return this.props.variants?.[name];
|
|
9689
9631
|
}
|
|
9690
9632
|
/**
|
|
9691
9633
|
* Returns the defined default transition on this component.
|
|
@@ -9723,11 +9665,8 @@
|
|
|
9723
9665
|
*/
|
|
9724
9666
|
removeValue(key) {
|
|
9725
9667
|
this.values.delete(key);
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
unsubscribe();
|
|
9729
|
-
this.valueSubscriptions.delete(key);
|
|
9730
|
-
}
|
|
9668
|
+
this.valueSubscriptions.get(key)?.();
|
|
9669
|
+
this.valueSubscriptions.delete(key);
|
|
9731
9670
|
delete this.latestValues[key];
|
|
9732
9671
|
this.removeValueFromRenderState(key, this.renderState);
|
|
9733
9672
|
}
|
|
@@ -9738,10 +9677,10 @@
|
|
|
9738
9677
|
return this.values.has(key);
|
|
9739
9678
|
}
|
|
9740
9679
|
getValue(key, defaultValue) {
|
|
9741
|
-
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
|
|
9680
|
+
let value = this.props.values?.[key];
|
|
9681
|
+
if (value)
|
|
9682
|
+
return value;
|
|
9683
|
+
value = this.values.get(key);
|
|
9745
9684
|
if (value === undefined && defaultValue !== undefined) {
|
|
9746
9685
|
value = motionValue(defaultValue ?? this.getDefaultValue?.(key), {
|
|
9747
9686
|
owner: this,
|
|
@@ -9791,15 +9730,11 @@
|
|
|
9791
9730
|
this.baseTarget[key] = value;
|
|
9792
9731
|
}
|
|
9793
9732
|
on(eventName, callback) {
|
|
9794
|
-
|
|
9795
|
-
this.events[eventName] = new motionUtils.SubscriptionManager();
|
|
9796
|
-
}
|
|
9797
|
-
return this.events[eventName].add(callback);
|
|
9733
|
+
return (this.events[eventName] ||
|
|
9734
|
+
(this.events[eventName] = new motionUtils.SubscriptionManager())).add(callback);
|
|
9798
9735
|
}
|
|
9799
9736
|
notify(eventName, ...args) {
|
|
9800
|
-
|
|
9801
|
-
this.events[eventName].notify(...args);
|
|
9802
|
-
}
|
|
9737
|
+
this.events[eventName]?.notify(...args);
|
|
9803
9738
|
}
|
|
9804
9739
|
scheduleRenderMicrotask() {
|
|
9805
9740
|
microtask.render(this.render);
|
|
@@ -9965,7 +9900,7 @@
|
|
|
9965
9900
|
let ancestor = element.parentElement;
|
|
9966
9901
|
while (ancestor) {
|
|
9967
9902
|
const node = layoutNodes.get(ancestor);
|
|
9968
|
-
if (node
|
|
9903
|
+
if (node?.instance)
|
|
9969
9904
|
return node;
|
|
9970
9905
|
ancestor = ancestor.parentElement;
|
|
9971
9906
|
}
|
|
@@ -10231,7 +10166,7 @@
|
|
|
10231
10166
|
hasSurvivor &&
|
|
10232
10167
|
!newMemberIds.has(layoutId)) {
|
|
10233
10168
|
if (restore && restore.parent.isConnected) {
|
|
10234
|
-
restore.parent.insertBefore(element, restore.next
|
|
10169
|
+
restore.parent.insertBefore(element, restore.next?.parentNode === restore.parent
|
|
10235
10170
|
? restore.next
|
|
10236
10171
|
: null);
|
|
10237
10172
|
node.isPresent = false;
|
|
@@ -10436,10 +10371,6 @@
|
|
|
10436
10371
|
* Scroll positions of scrollable ancestors and window.
|
|
10437
10372
|
*/
|
|
10438
10373
|
this.scrollPositions = new Map();
|
|
10439
|
-
/**
|
|
10440
|
-
* Cleanup function for scroll listeners.
|
|
10441
|
-
*/
|
|
10442
|
-
this.removeScrollListeners = null;
|
|
10443
10374
|
this.onElementScroll = (event) => {
|
|
10444
10375
|
this.handleScroll(event.target);
|
|
10445
10376
|
};
|
|
@@ -10467,10 +10398,10 @@
|
|
|
10467
10398
|
this.history.push({ ...point, timestamp: time.now() });
|
|
10468
10399
|
const { onStart, onMove } = this.handlers;
|
|
10469
10400
|
if (!isPanStarted) {
|
|
10470
|
-
onStart
|
|
10401
|
+
onStart?.(this.lastMoveEvent, info);
|
|
10471
10402
|
this.startEvent = this.lastMoveEvent;
|
|
10472
10403
|
}
|
|
10473
|
-
onMove
|
|
10404
|
+
onMove?.(this.lastMoveEvent, info);
|
|
10474
10405
|
};
|
|
10475
10406
|
this.handlePointerMove = (event, info) => {
|
|
10476
10407
|
/**
|
|
@@ -10495,17 +10426,15 @@
|
|
|
10495
10426
|
// Resume animation if dragSnapToOrigin is set OR if no drag started (user just clicked)
|
|
10496
10427
|
// This ensures constraint animations continue when interrupted by a click
|
|
10497
10428
|
if (this.dragSnapToOrigin || !this.startEvent) {
|
|
10498
|
-
resumeAnimation
|
|
10429
|
+
resumeAnimation?.();
|
|
10499
10430
|
}
|
|
10500
10431
|
if (!(this.lastMoveEvent && this.lastMoveEventInfo))
|
|
10501
10432
|
return;
|
|
10502
10433
|
const panInfo = getPanInfo(event.type === "pointercancel"
|
|
10503
10434
|
? this.lastMoveEventInfo
|
|
10504
10435
|
: transformPoint(info, this.transformPagePoint), this.history);
|
|
10505
|
-
|
|
10506
|
-
|
|
10507
|
-
}
|
|
10508
|
-
onSessionEnd && onSessionEnd(event, panInfo);
|
|
10436
|
+
this.startEvent && onEnd?.(event, panInfo);
|
|
10437
|
+
onSessionEnd?.(event, panInfo);
|
|
10509
10438
|
};
|
|
10510
10439
|
// If we have more than one touch, don't start detecting this gesture
|
|
10511
10440
|
if (!isPrimaryPointer(event))
|
|
@@ -10518,8 +10447,13 @@
|
|
|
10518
10447
|
const info = extractEventInfo(event);
|
|
10519
10448
|
const initialInfo = transformPoint(info, this.transformPagePoint);
|
|
10520
10449
|
const { point } = initialInfo;
|
|
10521
|
-
|
|
10522
|
-
|
|
10450
|
+
/**
|
|
10451
|
+
* Stamp the origin with time.now(), not frameData.timestamp: when
|
|
10452
|
+
* the frameloop is idle, frameData.timestamp is from the last frame
|
|
10453
|
+
* that ran, which can be seconds old, and a fast flick from a
|
|
10454
|
+
* standstill would then report near-zero velocity. See #1747.
|
|
10455
|
+
*/
|
|
10456
|
+
this.history = [{ ...point, timestamp: time.now() }];
|
|
10523
10457
|
const { onSessionStart } = handlers;
|
|
10524
10458
|
onSessionStart &&
|
|
10525
10459
|
onSessionStart(event, getPanInfo(initialInfo, this.history));
|
|
@@ -10543,30 +10477,19 @@
|
|
|
10543
10477
|
const style = getComputedStyle(current);
|
|
10544
10478
|
if (overflowStyles.has(style.overflowX) ||
|
|
10545
10479
|
overflowStyles.has(style.overflowY)) {
|
|
10546
|
-
this.scrollPositions.set(current,
|
|
10547
|
-
x: current.scrollLeft,
|
|
10548
|
-
y: current.scrollTop,
|
|
10549
|
-
});
|
|
10480
|
+
this.scrollPositions.set(current, getScroll(current));
|
|
10550
10481
|
}
|
|
10551
10482
|
current = current.parentElement;
|
|
10552
10483
|
}
|
|
10553
10484
|
// Track window scroll
|
|
10554
|
-
this.scrollPositions.set(window,
|
|
10555
|
-
|
|
10556
|
-
y: window.scrollY,
|
|
10557
|
-
});
|
|
10485
|
+
this.scrollPositions.set(window, getScroll(window));
|
|
10486
|
+
this.removeScrollListeners = motionUtils.pipe(
|
|
10558
10487
|
// Capture listener catches element scroll events as they bubble
|
|
10559
|
-
window
|
|
10488
|
+
addDomEvent(window, "scroll", this.onElementScroll, {
|
|
10560
10489
|
capture: true,
|
|
10561
|
-
})
|
|
10490
|
+
}),
|
|
10562
10491
|
// Direct window scroll listener (window scroll doesn't bubble)
|
|
10563
|
-
window
|
|
10564
|
-
this.removeScrollListeners = () => {
|
|
10565
|
-
window.removeEventListener("scroll", this.onElementScroll, {
|
|
10566
|
-
capture: true,
|
|
10567
|
-
});
|
|
10568
|
-
window.removeEventListener("scroll", this.onWindowScroll);
|
|
10569
|
-
};
|
|
10492
|
+
addDomEvent(window, "scroll", this.onWindowScroll, {}));
|
|
10570
10493
|
}
|
|
10571
10494
|
/**
|
|
10572
10495
|
* Handle scroll compensation during drag.
|
|
@@ -10579,12 +10502,7 @@
|
|
|
10579
10502
|
if (!initial)
|
|
10580
10503
|
return;
|
|
10581
10504
|
const isWindow = target === window;
|
|
10582
|
-
const current =
|
|
10583
|
-
? { x: window.scrollX, y: window.scrollY }
|
|
10584
|
-
: {
|
|
10585
|
-
x: target.scrollLeft,
|
|
10586
|
-
y: target.scrollTop,
|
|
10587
|
-
};
|
|
10505
|
+
const current = getScroll(target);
|
|
10588
10506
|
const delta = { x: current.x - initial.x, y: current.y - initial.y };
|
|
10589
10507
|
if (delta.x === 0 && delta.y === 0)
|
|
10590
10508
|
return;
|
|
@@ -10609,12 +10527,18 @@
|
|
|
10609
10527
|
this.handlers = handlers;
|
|
10610
10528
|
}
|
|
10611
10529
|
end() {
|
|
10612
|
-
this.removeListeners
|
|
10613
|
-
this.removeScrollListeners
|
|
10530
|
+
this.removeListeners?.();
|
|
10531
|
+
this.removeScrollListeners?.();
|
|
10614
10532
|
this.scrollPositions.clear();
|
|
10615
10533
|
cancelFrame(this.updatePoint);
|
|
10616
10534
|
}
|
|
10617
10535
|
}
|
|
10536
|
+
const getScroll = (target) => target === window
|
|
10537
|
+
? { x: window.scrollX, y: window.scrollY }
|
|
10538
|
+
: {
|
|
10539
|
+
x: target.scrollLeft,
|
|
10540
|
+
y: target.scrollTop,
|
|
10541
|
+
};
|
|
10618
10542
|
function transformPoint(info, transformPagePoint) {
|
|
10619
10543
|
return transformPagePoint ? { point: transformPagePoint(info.point) } : info;
|
|
10620
10544
|
}
|
|
@@ -10871,6 +10795,25 @@
|
|
|
10871
10795
|
: dragElastic[label] || 0;
|
|
10872
10796
|
}
|
|
10873
10797
|
|
|
10798
|
+
/**
|
|
10799
|
+
* Re-read the scroll of the projection's ancestors, and return that of the
|
|
10800
|
+
* `layoutScroll` ones as a key that changes when any of them scroll.
|
|
10801
|
+
*
|
|
10802
|
+
* Clear the cached scroll first so `updateScroll` bypasses its
|
|
10803
|
+
* per-animationId cache and re-reads the live value.
|
|
10804
|
+
*/
|
|
10805
|
+
function measureScroll(projection) {
|
|
10806
|
+
let key = "";
|
|
10807
|
+
for (const node of projection.path) {
|
|
10808
|
+
node.scroll = undefined;
|
|
10809
|
+
node.updateScroll();
|
|
10810
|
+
const { scroll } = node;
|
|
10811
|
+
if (node !== projection.root && scroll) {
|
|
10812
|
+
key += scroll.offset.x + "," + scroll.offset.y + ",";
|
|
10813
|
+
}
|
|
10814
|
+
}
|
|
10815
|
+
return key;
|
|
10816
|
+
}
|
|
10874
10817
|
const elementDragControls = new WeakMap();
|
|
10875
10818
|
class VisualElementDragControls {
|
|
10876
10819
|
constructor(visualElement, readProps = () => visualElement.getProps()) {
|
|
@@ -10902,8 +10845,7 @@
|
|
|
10902
10845
|
/**
|
|
10903
10846
|
* Don't start dragging if this component is exiting
|
|
10904
10847
|
*/
|
|
10905
|
-
|
|
10906
|
-
if (presenceContext && presenceContext.isPresent === false)
|
|
10848
|
+
if (this.visualElement.presenceContext?.isPresent === false)
|
|
10907
10849
|
return;
|
|
10908
10850
|
const onSessionStart = (event) => {
|
|
10909
10851
|
if (snapToCursor)
|
|
@@ -10914,8 +10856,7 @@
|
|
|
10914
10856
|
// Attempt to grab the global drag gesture lock - maybe make this part of PanSession
|
|
10915
10857
|
const { drag, dragPropagation, onDragStart } = this.getProps();
|
|
10916
10858
|
if (drag && !dragPropagation) {
|
|
10917
|
-
|
|
10918
|
-
this.openDragLock();
|
|
10859
|
+
this.openDragLock?.();
|
|
10919
10860
|
this.openDragLock = setDragLock(drag);
|
|
10920
10861
|
// If we don 't have the lock, don't start dragging
|
|
10921
10862
|
if (!this.openDragLock)
|
|
@@ -10926,9 +10867,10 @@
|
|
|
10926
10867
|
this.isDragging = true;
|
|
10927
10868
|
this.currentDirection = null;
|
|
10928
10869
|
this.resolveConstraints();
|
|
10929
|
-
|
|
10930
|
-
|
|
10931
|
-
|
|
10870
|
+
const { projection } = this.visualElement;
|
|
10871
|
+
if (projection) {
|
|
10872
|
+
projection.isAnimationBlocked = true;
|
|
10873
|
+
projection.target = undefined;
|
|
10932
10874
|
}
|
|
10933
10875
|
/**
|
|
10934
10876
|
* Record gesture origin and pointer offset
|
|
@@ -10950,13 +10892,11 @@
|
|
|
10950
10892
|
current = parseFloat(current);
|
|
10951
10893
|
}
|
|
10952
10894
|
else if (percent.test(current)) {
|
|
10953
|
-
const
|
|
10954
|
-
if (
|
|
10955
|
-
|
|
10956
|
-
|
|
10957
|
-
|
|
10958
|
-
current = length * (parseFloat(current) / 100);
|
|
10959
|
-
}
|
|
10895
|
+
const measuredAxis = projection?.layout?.layoutBox[axis];
|
|
10896
|
+
if (measuredAxis) {
|
|
10897
|
+
current =
|
|
10898
|
+
calcLength(measuredAxis) *
|
|
10899
|
+
(parseFloat(current) / 100);
|
|
10960
10900
|
}
|
|
10961
10901
|
}
|
|
10962
10902
|
this.originPoint[axis] = current;
|
|
@@ -10966,8 +10906,7 @@
|
|
|
10966
10906
|
frame.update(() => onDragStart(event, info), false, true);
|
|
10967
10907
|
}
|
|
10968
10908
|
addValueToWillChange(this.visualElement, "transform");
|
|
10969
|
-
|
|
10970
|
-
animationState && animationState.setActive("whileDrag", true);
|
|
10909
|
+
this.visualElement.animationState?.setActive("whileDrag", true);
|
|
10971
10910
|
};
|
|
10972
10911
|
const onMove = (event, info) => {
|
|
10973
10912
|
this.latestPointerEvent = event;
|
|
@@ -10990,8 +10929,8 @@
|
|
|
10990
10929
|
onDirectionLock && onDirectionLock(this.currentDirection);
|
|
10991
10930
|
}
|
|
10992
10931
|
// Update each point with the latest position
|
|
10993
|
-
this.updateAxis("x",
|
|
10994
|
-
this.updateAxis("y",
|
|
10932
|
+
this.updateAxis("x", offset);
|
|
10933
|
+
this.updateAxis("y", offset);
|
|
10995
10934
|
/**
|
|
10996
10935
|
* Ideally we would leave the renderer to fire naturally at the end of
|
|
10997
10936
|
* this frame but if the element is about to change layout as the result
|
|
@@ -11060,12 +10999,11 @@
|
|
|
11060
10999
|
projection.isAnimationBlocked = false;
|
|
11061
11000
|
}
|
|
11062
11001
|
this.endPanSession();
|
|
11063
|
-
|
|
11064
|
-
if (!dragPropagation && this.openDragLock) {
|
|
11002
|
+
if (!this.getProps().dragPropagation && this.openDragLock) {
|
|
11065
11003
|
this.openDragLock();
|
|
11066
11004
|
this.openDragLock = null;
|
|
11067
11005
|
}
|
|
11068
|
-
animationState
|
|
11006
|
+
animationState?.setActive("whileDrag", false);
|
|
11069
11007
|
}
|
|
11070
11008
|
/**
|
|
11071
11009
|
* Clean up the pan session without modifying other drag state.
|
|
@@ -11073,31 +11011,42 @@
|
|
|
11073
11011
|
* without affecting projection animations or drag locks.
|
|
11074
11012
|
*/
|
|
11075
11013
|
endPanSession() {
|
|
11076
|
-
this.panSession
|
|
11014
|
+
this.panSession?.end();
|
|
11077
11015
|
this.panSession = undefined;
|
|
11078
11016
|
}
|
|
11079
|
-
updateAxis(axis,
|
|
11080
|
-
|
|
11017
|
+
updateAxis(axis, offset) {
|
|
11018
|
+
/**
|
|
11019
|
+
* Read drag per axis: a callback fired while updating the x axis
|
|
11020
|
+
* can synchronously re-render with new props.
|
|
11021
|
+
*/
|
|
11022
|
+
const { drag } = this.readProps();
|
|
11081
11023
|
// If we're not dragging this axis, do an early return.
|
|
11082
11024
|
if (!offset || !shouldDrag(axis, drag, this.currentDirection))
|
|
11083
11025
|
return;
|
|
11084
11026
|
const axisValue = this.getAxisMotionValue(axis);
|
|
11085
11027
|
let next = this.originPoint[axis] + offset[axis];
|
|
11086
11028
|
// Apply constraints
|
|
11087
|
-
|
|
11088
|
-
|
|
11029
|
+
const constraints = this.constraints && this.constraints[axis];
|
|
11030
|
+
if (constraints) {
|
|
11031
|
+
next = applyConstraints(next, constraints, this.elastic[axis]);
|
|
11089
11032
|
}
|
|
11090
11033
|
axisValue.set(next);
|
|
11091
11034
|
}
|
|
11092
11035
|
resolveConstraints() {
|
|
11093
11036
|
const { dragConstraints, dragElastic } = this.getProps();
|
|
11094
|
-
const
|
|
11095
|
-
|
|
11096
|
-
? this.visualElement.projection.measure(false)
|
|
11097
|
-
: this.visualElement.projection?.layout;
|
|
11037
|
+
const { projection } = this.visualElement;
|
|
11038
|
+
const layout = projection && (projection.layout || projection.measure(false));
|
|
11098
11039
|
const prevConstraints = this.constraints;
|
|
11099
11040
|
if (isElementConstraints(dragConstraints)) {
|
|
11100
|
-
|
|
11041
|
+
/**
|
|
11042
|
+
* Ref constraints are measured with the layout. Scrolling a
|
|
11043
|
+
* `layoutScroll` ancestor since can move the element relative
|
|
11044
|
+
* to them without a layout measurement, so measure them again
|
|
11045
|
+
* (#2024). Otherwise keep them: they and the layout can both
|
|
11046
|
+
* have moved on the page since, e.g. when content above grows.
|
|
11047
|
+
*/
|
|
11048
|
+
if (!this.constraints ||
|
|
11049
|
+
this.scroll !== measureScroll(projection)) {
|
|
11101
11050
|
this.constraints = this.resolveRefConstraints();
|
|
11102
11051
|
}
|
|
11103
11052
|
}
|
|
@@ -11140,21 +11089,20 @@
|
|
|
11140
11089
|
if (!projection || !projection.layout)
|
|
11141
11090
|
return false;
|
|
11142
11091
|
/**
|
|
11143
|
-
* Refresh the
|
|
11144
|
-
*
|
|
11145
|
-
*
|
|
11146
|
-
*
|
|
11147
|
-
*
|
|
11148
|
-
*
|
|
11149
|
-
* Clear the cached scroll first so `updateScroll` bypasses its
|
|
11150
|
-
* per-animationId cache and re-reads the live value.
|
|
11092
|
+
* Refresh the scroll offsets of the root and `layoutScroll`
|
|
11093
|
+
* ancestors so the constraint's viewport box translates to the
|
|
11094
|
+
* layout's coordinates. The scroll captured when the layout was
|
|
11095
|
+
* measured can be stale if they've scrolled since — e.g. via the
|
|
11096
|
+
* browser restoring scroll on refresh, or an ancestor layout effect
|
|
11097
|
+
* running after this element's mount (#2829).
|
|
11151
11098
|
*/
|
|
11152
|
-
|
|
11153
|
-
projection.root.scroll = undefined;
|
|
11154
|
-
projection.root.updateScroll();
|
|
11155
|
-
}
|
|
11099
|
+
this.scroll = measureScroll(projection);
|
|
11156
11100
|
const constraintsBox = measurePageBox(constraintsElement, projection.root, this.visualElement.getTransformPagePoint());
|
|
11157
|
-
|
|
11101
|
+
/**
|
|
11102
|
+
* layoutBox removes the scroll of `layoutScroll` ancestors, so
|
|
11103
|
+
* remove it from the constraints box too.
|
|
11104
|
+
*/
|
|
11105
|
+
let measuredConstraints = calcViewportConstraints(projection.layout.layoutBox, projection.removeElementScroll(constraintsBox));
|
|
11158
11106
|
/**
|
|
11159
11107
|
* If there's an onMeasureDragConstraints listener we call it and
|
|
11160
11108
|
* if different constraints are returned, set constraints to that
|
|
@@ -11175,7 +11123,7 @@
|
|
|
11175
11123
|
if (!shouldDrag(axis, dragAxes || drag, this.currentDirection)) {
|
|
11176
11124
|
return;
|
|
11177
11125
|
}
|
|
11178
|
-
let transition =
|
|
11126
|
+
let transition = constraints[axis] || {};
|
|
11179
11127
|
if (dragSnapToOrigin === true ||
|
|
11180
11128
|
dragSnapToOrigin === axis)
|
|
11181
11129
|
transition = { min: 0, max: 0 };
|
|
@@ -11281,7 +11229,7 @@
|
|
|
11281
11229
|
this.visualElement.current.style.transform = transformTemplate
|
|
11282
11230
|
? transformTemplate({}, "")
|
|
11283
11231
|
: "none";
|
|
11284
|
-
projection.root
|
|
11232
|
+
projection.root?.updateScroll();
|
|
11285
11233
|
projection.updateLayout();
|
|
11286
11234
|
/**
|
|
11287
11235
|
* Reset constraints so resolveConstraints() will recalculate them
|
|
@@ -11358,8 +11306,8 @@
|
|
|
11358
11306
|
};
|
|
11359
11307
|
const { projection } = this.visualElement;
|
|
11360
11308
|
const stopMeasureLayoutListener = projection.addEventListener("measure", measureDragConstraints);
|
|
11361
|
-
if (
|
|
11362
|
-
projection.root
|
|
11309
|
+
if (!projection.layout) {
|
|
11310
|
+
projection.root?.updateScroll();
|
|
11363
11311
|
projection.updateLayout();
|
|
11364
11312
|
}
|
|
11365
11313
|
frame.read(measureDragConstraints);
|
|
@@ -11394,22 +11342,14 @@
|
|
|
11394
11342
|
stopResizeListener();
|
|
11395
11343
|
stopPointerListener();
|
|
11396
11344
|
stopMeasureLayoutListener();
|
|
11397
|
-
stopLayoutUpdateListener
|
|
11398
|
-
stopResizeObservers
|
|
11345
|
+
stopLayoutUpdateListener();
|
|
11346
|
+
stopResizeObservers?.();
|
|
11399
11347
|
};
|
|
11400
11348
|
}
|
|
11401
11349
|
getProps() {
|
|
11402
11350
|
const props = this.readProps();
|
|
11403
|
-
const {
|
|
11404
|
-
return {
|
|
11405
|
-
...props,
|
|
11406
|
-
drag,
|
|
11407
|
-
dragDirectionLock,
|
|
11408
|
-
dragPropagation,
|
|
11409
|
-
dragConstraints,
|
|
11410
|
-
dragElastic,
|
|
11411
|
-
dragMomentum,
|
|
11412
|
-
};
|
|
11351
|
+
const { dragElastic = defaultElastic, dragMomentum = true } = props;
|
|
11352
|
+
return { ...props, dragElastic, dragMomentum };
|
|
11413
11353
|
}
|
|
11414
11354
|
}
|
|
11415
11355
|
/**
|
|
@@ -13744,6 +13684,12 @@
|
|
|
13744
13684
|
}
|
|
13745
13685
|
|
|
13746
13686
|
const reversePriorityOrder = [...variantPriorityOrder].reverse();
|
|
13687
|
+
/**
|
|
13688
|
+
* The transition a value uses when it leaves a state (#1725): the state's
|
|
13689
|
+
* own transition when `out: true`, or the `out` transition itself.
|
|
13690
|
+
* Value-specific keys are resolved by animateTarget.
|
|
13691
|
+
*/
|
|
13692
|
+
const getOutTransition = (transition) => transition?.out === true ? transition : transition?.out;
|
|
13747
13693
|
/**
|
|
13748
13694
|
* Diffs the element's animation props (one layer per AnimationType, highest
|
|
13749
13695
|
* priority wins each value) against the previous call and starts animations
|
|
@@ -13765,13 +13711,18 @@
|
|
|
13765
13711
|
let wasReset = false;
|
|
13766
13712
|
function animateChanges(changedActiveType) {
|
|
13767
13713
|
const { props, parent, manuallyAnimateOnMount } = visualElement;
|
|
13714
|
+
const { initial } = props;
|
|
13768
13715
|
const isMounting = isInitialRender || wasReset;
|
|
13769
13716
|
const animations = [];
|
|
13717
|
+
const resolveInitial = (definition = initial) => (typeof definition !== "boolean" &&
|
|
13718
|
+
resolveVariant(visualElement, Array.isArray(definition) ? definition[0] : definition, visualElement.presenceContext?.custom)) ||
|
|
13719
|
+
undefined;
|
|
13770
13720
|
/**
|
|
13771
|
-
* Values removed from a type
|
|
13772
|
-
*
|
|
13721
|
+
* Values removed from a type, mapped to the out transition of the
|
|
13722
|
+
* state they're leaving. A lower-priority type that defines them
|
|
13723
|
+
* animates them back, otherwise they fall back to a base target.
|
|
13773
13724
|
*/
|
|
13774
|
-
const removedKeys = new
|
|
13725
|
+
const removedKeys = new Map();
|
|
13775
13726
|
/**
|
|
13776
13727
|
* Values claimed by active, higher-priority types.
|
|
13777
13728
|
*/
|
|
@@ -13789,6 +13740,13 @@
|
|
|
13789
13740
|
do
|
|
13790
13741
|
source = source.props.inherit !== false && source.parent;
|
|
13791
13742
|
while (source && !source.isControllingVariants);
|
|
13743
|
+
/**
|
|
13744
|
+
* Mounting leaves initial, so values use its out transition. Like the
|
|
13745
|
+
* other types, variant children inherit initial's label.
|
|
13746
|
+
*/
|
|
13747
|
+
const initialOut = isMounting &&
|
|
13748
|
+
getOutTransition(resolveInitial(initial ?? (source && source.props.initial))
|
|
13749
|
+
?.transition);
|
|
13792
13750
|
reversePriorityOrder.forEach((type, i) => {
|
|
13793
13751
|
const typeState = state[type];
|
|
13794
13752
|
const ownProp = props[type];
|
|
@@ -13800,8 +13758,6 @@
|
|
|
13800
13758
|
: undefined;
|
|
13801
13759
|
const propIsVariant = isVariantLabel(prop);
|
|
13802
13760
|
const activeDelta = type === changedActiveType ? typeState.isActive : null;
|
|
13803
|
-
if (activeDelta === false)
|
|
13804
|
-
removedVariantIndex = i;
|
|
13805
13761
|
/**
|
|
13806
13762
|
* Inherited labels are animated by the parent through
|
|
13807
13763
|
* variantChildren, unless this element mounted after its parent.
|
|
@@ -13816,6 +13772,13 @@
|
|
|
13816
13772
|
typeof prop === "boolean") {
|
|
13817
13773
|
return;
|
|
13818
13774
|
}
|
|
13775
|
+
/**
|
|
13776
|
+
* Set after the skip above, so deactivating a type that has nothing
|
|
13777
|
+
* to animate (e.g. whileTap with no prop) doesn't re-run the variants
|
|
13778
|
+
* below it.
|
|
13779
|
+
*/
|
|
13780
|
+
if (activeDelta === false)
|
|
13781
|
+
removedVariantIndex = i;
|
|
13819
13782
|
/**
|
|
13820
13783
|
* Don't re-resolve a running exit: a changed custom would start
|
|
13821
13784
|
* new value animations that stop the originals, leaving the exit
|
|
@@ -13835,6 +13798,7 @@
|
|
|
13835
13798
|
let handledRemovedValues = false;
|
|
13836
13799
|
const definitionList = Array.isArray(prop) ? prop : [prop];
|
|
13837
13800
|
let resolvedValues = {};
|
|
13801
|
+
let out;
|
|
13838
13802
|
if (activeDelta !== false) {
|
|
13839
13803
|
for (const definition of definitionList) {
|
|
13840
13804
|
const { transition, transitionEnd, ...target } = resolveVariant(visualElement, definition, getTypeCustom(visualElement, type)) || {};
|
|
@@ -13843,6 +13807,11 @@
|
|
|
13843
13807
|
...target,
|
|
13844
13808
|
...transitionEnd,
|
|
13845
13809
|
};
|
|
13810
|
+
/**
|
|
13811
|
+
* One out transition per type. With a list of labels,
|
|
13812
|
+
* the last one that sets out applies to all its values.
|
|
13813
|
+
*/
|
|
13814
|
+
out = getOutTransition(transition) || out;
|
|
13846
13815
|
}
|
|
13847
13816
|
}
|
|
13848
13817
|
const { prevResolvedValues } = typeState;
|
|
@@ -13858,12 +13827,18 @@
|
|
|
13858
13827
|
const valueHasChanged = Array.isArray(next) && Array.isArray(prev)
|
|
13859
13828
|
? !shallowCompare(next, prev) || variantDidChange
|
|
13860
13829
|
: next !== prev;
|
|
13830
|
+
let outTransition;
|
|
13861
13831
|
if (valueHasChanged && (next === undefined || next === null)) {
|
|
13862
|
-
|
|
13832
|
+
/**
|
|
13833
|
+
* The highest-priority state a value leaves wins.
|
|
13834
|
+
*/
|
|
13835
|
+
removedKeys.has(key) ||
|
|
13836
|
+
removedKeys.set(key, typeState.prevOut);
|
|
13863
13837
|
}
|
|
13864
13838
|
else if (valueHasChanged ||
|
|
13865
13839
|
(next !== undefined && removedKeys.has(key))) {
|
|
13866
13840
|
shouldAnimateType = true;
|
|
13841
|
+
outTransition = removedKeys.get(key) || initialOut;
|
|
13867
13842
|
if (removedKeys.delete(key))
|
|
13868
13843
|
handledRemovedValues = true;
|
|
13869
13844
|
typeState.needsAnimating[key] = true;
|
|
@@ -13874,9 +13849,11 @@
|
|
|
13874
13849
|
else {
|
|
13875
13850
|
typeState.protectedKeys[key] = true;
|
|
13876
13851
|
}
|
|
13852
|
+
typeState.out[key] = outTransition;
|
|
13877
13853
|
}
|
|
13878
13854
|
typeState.prevProp = prop;
|
|
13879
13855
|
typeState.prevResolvedValues = resolvedValues;
|
|
13856
|
+
typeState.prevOut = out;
|
|
13880
13857
|
if (typeState.isActive) {
|
|
13881
13858
|
encounteredKeys = { ...encounteredKeys, ...resolvedValues };
|
|
13882
13859
|
}
|
|
@@ -13907,14 +13884,17 @@
|
|
|
13907
13884
|
* longer defines a value it once did, it stays where it is.
|
|
13908
13885
|
*/
|
|
13909
13886
|
if (removedKeys.size) {
|
|
13910
|
-
const { initial } = props;
|
|
13911
13887
|
const fallbackAnimation = {};
|
|
13912
|
-
const resolvedInitial =
|
|
13913
|
-
|
|
13914
|
-
|
|
13915
|
-
|
|
13916
|
-
|
|
13917
|
-
|
|
13888
|
+
const resolvedInitial = resolveInitial();
|
|
13889
|
+
let fallbackTransition = resolvedInitial?.transition;
|
|
13890
|
+
removedKeys.forEach((outTransition, key) => {
|
|
13891
|
+
if (outTransition) {
|
|
13892
|
+
fallbackTransition = {
|
|
13893
|
+
...(fallbackTransition ||
|
|
13894
|
+
visualElement.getDefaultTransition()),
|
|
13895
|
+
[key]: outTransition,
|
|
13896
|
+
};
|
|
13897
|
+
}
|
|
13918
13898
|
const motionValue = visualElement.getValue(key);
|
|
13919
13899
|
if (motionValue)
|
|
13920
13900
|
motionValue.liveStyle = true;
|
|
@@ -13945,6 +13925,9 @@
|
|
|
13945
13925
|
visualElement.baseTarget[key] = motionValue?.get();
|
|
13946
13926
|
}
|
|
13947
13927
|
});
|
|
13928
|
+
if (fallbackTransition) {
|
|
13929
|
+
fallbackAnimation.transition = fallbackTransition;
|
|
13930
|
+
}
|
|
13948
13931
|
animations.push({ animation: fallbackAnimation });
|
|
13949
13932
|
}
|
|
13950
13933
|
const blockAnimation = (isMounting && visualElement.blockInitialAnimation) ||
|
|
@@ -14004,6 +13987,7 @@
|
|
|
14004
13987
|
protectedKeys: {},
|
|
14005
13988
|
needsAnimating: {},
|
|
14006
13989
|
prevResolvedValues: {},
|
|
13990
|
+
out: {},
|
|
14007
13991
|
};
|
|
14008
13992
|
}
|
|
14009
13993
|
return state;
|
|
@@ -14170,6 +14154,7 @@
|
|
|
14170
14154
|
exports.buildSVGAttrs = buildSVGAttrs;
|
|
14171
14155
|
exports.buildSVGPath = buildSVGPath;
|
|
14172
14156
|
exports.buildTransform = buildTransform$1;
|
|
14157
|
+
exports.buildTransformer = buildTransformer;
|
|
14173
14158
|
exports.calcAxisDelta = calcAxisDelta;
|
|
14174
14159
|
exports.calcBoxDelta = calcBoxDelta;
|
|
14175
14160
|
exports.calcChildStagger = calcChildStagger;
|