motion-dom 13.5.0 → 13.5.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 +284 -443
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/NativeAnimation.mjs +4 -1
- package/dist/es/animation/NativeAnimation.mjs.map +1 -1
- package/dist/es/animation/interfaces/visual-element-target.mjs +2 -4
- package/dist/es/animation/interfaces/visual-element-target.mjs.map +1 -1
- package/dist/es/animation/interfaces/visual-element-variant.mjs +29 -49
- package/dist/es/animation/interfaces/visual-element-variant.mjs.map +1 -1
- package/dist/es/animation/interfaces/visual-element.mjs +5 -14
- package/dist/es/animation/interfaces/visual-element.mjs.map +1 -1
- package/dist/es/effects/MotionValueState.mjs +6 -1
- package/dist/es/effects/MotionValueState.mjs.map +1 -1
- package/dist/es/effects/style/index.mjs +1 -1
- package/dist/es/effects/style/index.mjs.map +1 -1
- package/dist/es/effects/svg/index.mjs +18 -7
- package/dist/es/effects/svg/index.mjs.map +1 -1
- package/dist/es/index.mjs +2 -1
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/render/VisualElement.mjs +17 -57
- package/dist/es/render/VisualElement.mjs.map +1 -1
- package/dist/es/render/utils/animation-state.mjs +144 -267
- package/dist/es/render/utils/animation-state.mjs.map +1 -1
- package/dist/es/render/utils/resolve-dynamic-variants.mjs +7 -3
- package/dist/es/render/utils/resolve-dynamic-variants.mjs.map +1 -1
- package/dist/es/render/utils/resolve-variants.mjs +8 -19
- package/dist/es/render/utils/resolve-variants.mjs.map +1 -1
- package/dist/es/scroll/observe.mjs +23 -0
- package/dist/es/scroll/observe.mjs.map +1 -0
- package/dist/index.d.ts +36 -27
- package/dist/motion-dom.dev.js +284 -443
- package/dist/motion-dom.js +1 -1
- package/dist/size-rollup-style-effect.js +1 -1
- package/dist/size-rollup-style-effect.js.map +1 -1
- package/package.json +3 -3
package/dist/motion-dom.dev.js
CHANGED
|
@@ -2732,13 +2732,16 @@
|
|
|
2732
2732
|
/**
|
|
2733
2733
|
* Attaches a timeline to the animation, for instance the `ScrollTimeline`.
|
|
2734
2734
|
*/
|
|
2735
|
-
attachTimeline({ timeline, onAttach, observe,
|
|
2735
|
+
attachTimeline({ timeline, onAttach, observe,
|
|
2736
|
+
// Deprecated rangeStart/rangeEnd from framer-motion 13.0–13.4. Removed in v14.
|
|
2737
|
+
...range }) {
|
|
2736
2738
|
if (this.allowFlatten) {
|
|
2737
2739
|
this.animation.effect?.updateTiming({ easing: "linear" });
|
|
2738
2740
|
}
|
|
2739
2741
|
this.animation.onfinish = null;
|
|
2740
2742
|
if (timeline && supportsScrollTimeline()) {
|
|
2741
2743
|
this.animation.timeline = timeline;
|
|
2744
|
+
Object.assign(this.animation, range);
|
|
2742
2745
|
onAttach?.(this.animation);
|
|
2743
2746
|
return motionUtils.noop;
|
|
2744
2747
|
}
|
|
@@ -4076,36 +4079,29 @@
|
|
|
4076
4079
|
return state;
|
|
4077
4080
|
}
|
|
4078
4081
|
function resolveVariantFromProps(props, definition, custom, visualElement) {
|
|
4082
|
+
const resolveFunction = (def) => typeof def === "function"
|
|
4083
|
+
? def(custom !== undefined ? custom : props.custom, ...getValueState(visualElement))
|
|
4084
|
+
: def;
|
|
4079
4085
|
/**
|
|
4080
|
-
*
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
const [current, velocity] = getValueState(visualElement);
|
|
4084
|
-
definition = definition(custom !== undefined ? custom : props.custom, current, velocity);
|
|
4085
|
-
}
|
|
4086
|
-
/**
|
|
4087
|
-
* If the variant definition is a variant label, or
|
|
4088
|
-
* the function returned a variant label, resolve.
|
|
4086
|
+
* Resolve a function, then a variant label (which the function may have
|
|
4087
|
+
* returned), then a function again as the label may point to one. The
|
|
4088
|
+
* final function can only return a target object.
|
|
4089
4089
|
*/
|
|
4090
|
+
definition = resolveFunction(definition);
|
|
4090
4091
|
if (typeof definition === "string") {
|
|
4091
4092
|
definition = props.variants && props.variants[definition];
|
|
4092
4093
|
}
|
|
4093
|
-
|
|
4094
|
-
* At this point we've resolved both functions and variant labels,
|
|
4095
|
-
* but the resolved variant label might itself have been a function.
|
|
4096
|
-
* If so, resolve. This can only have returned a valid target object.
|
|
4097
|
-
*/
|
|
4098
|
-
if (typeof definition === "function") {
|
|
4099
|
-
const [current, velocity] = getValueState(visualElement);
|
|
4100
|
-
definition = definition(custom !== undefined ? custom : props.custom, current, velocity);
|
|
4101
|
-
}
|
|
4102
|
-
return definition;
|
|
4094
|
+
return resolveFunction(definition);
|
|
4103
4095
|
}
|
|
4104
4096
|
|
|
4105
4097
|
function resolveVariant(visualElement, definition, custom) {
|
|
4106
|
-
|
|
4107
|
-
return resolveVariantFromProps(props, definition, custom !== undefined ? custom : props.custom, visualElement);
|
|
4098
|
+
return resolveVariantFromProps(visualElement.getProps(), definition, custom, visualElement);
|
|
4108
4099
|
}
|
|
4100
|
+
/**
|
|
4101
|
+
* Exit variants resolve with AnimatePresence's custom, every other type
|
|
4102
|
+
* with the element's own.
|
|
4103
|
+
*/
|
|
4104
|
+
const getTypeCustom = (visualElement, type) => type === "exit" ? visualElement.presenceContext?.custom : undefined;
|
|
4109
4105
|
|
|
4110
4106
|
const positionalKeys = new Set([
|
|
4111
4107
|
"width",
|
|
@@ -4188,7 +4184,7 @@
|
|
|
4188
4184
|
* had been set to true in the meantime.
|
|
4189
4185
|
*/
|
|
4190
4186
|
function shouldBlockAnimation({ protectedKeys, needsAnimating }, key) {
|
|
4191
|
-
const shouldBlock =
|
|
4187
|
+
const shouldBlock = key in protectedKeys && !needsAnimating[key];
|
|
4192
4188
|
needsAnimating[key] = false;
|
|
4193
4189
|
return shouldBlock;
|
|
4194
4190
|
}
|
|
@@ -4203,9 +4199,7 @@
|
|
|
4203
4199
|
if (transitionOverride)
|
|
4204
4200
|
transition = transitionOverride;
|
|
4205
4201
|
const animations = [];
|
|
4206
|
-
const animationTypeState = type &&
|
|
4207
|
-
visualElement.animationState &&
|
|
4208
|
-
visualElement.animationState.getState()[type];
|
|
4202
|
+
const animationTypeState = type && visualElement.animationState?.getState()[type];
|
|
4209
4203
|
const path = transition?.path;
|
|
4210
4204
|
if (path) {
|
|
4211
4205
|
// path mutates `target` to claim x/y; loop below skips them.
|
|
@@ -4279,75 +4273,46 @@
|
|
|
4279
4273
|
}
|
|
4280
4274
|
|
|
4281
4275
|
function animateVariant(visualElement, variant, options = {}) {
|
|
4282
|
-
const resolved = resolveVariant(visualElement, variant, options.type
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
return animateChildren(visualElement, variant, forwardDelay, delayChildren, staggerChildren, staggerDirection, options);
|
|
4304
|
-
}
|
|
4305
|
-
: () => Promise.resolve();
|
|
4276
|
+
const resolved = resolveVariant(visualElement, variant, getTypeCustom(visualElement, options.type));
|
|
4277
|
+
const transition = options.transitionOverride ||
|
|
4278
|
+
(resolved?.transition ?? (visualElement.getDefaultTransition() || {}));
|
|
4279
|
+
const getAnimation = () => Promise.all(resolved ? animateTarget(visualElement, resolved, options) : []);
|
|
4280
|
+
const getChildAnimations = (delay = 0) => {
|
|
4281
|
+
const { variantChildren } = visualElement;
|
|
4282
|
+
const { delayChildren = 0, staggerChildren, staggerDirection, } = transition;
|
|
4283
|
+
const animations = [];
|
|
4284
|
+
variantChildren?.forEach((child) => {
|
|
4285
|
+
child.notify("AnimationStart", variant);
|
|
4286
|
+
animations.push(animateVariant(child, variant, {
|
|
4287
|
+
...options,
|
|
4288
|
+
delay: delay +
|
|
4289
|
+
(typeof delayChildren === "function"
|
|
4290
|
+
? 0
|
|
4291
|
+
: delayChildren) +
|
|
4292
|
+
calcChildStagger(variantChildren, child, delayChildren, staggerChildren, staggerDirection),
|
|
4293
|
+
}).then(() => child.notify("AnimationComplete", variant)));
|
|
4294
|
+
});
|
|
4295
|
+
return Promise.all(animations);
|
|
4296
|
+
};
|
|
4306
4297
|
/**
|
|
4307
|
-
*
|
|
4308
|
-
*
|
|
4298
|
+
* when: "beforeChildren" | "afterChildren" runs this element's animation
|
|
4299
|
+
* and its children's in sequence.
|
|
4309
4300
|
*/
|
|
4310
4301
|
const { when } = transition;
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
?
|
|
4314
|
-
:
|
|
4315
|
-
|
|
4316
|
-
}
|
|
4317
|
-
else {
|
|
4318
|
-
return Promise.all([getAnimation(), getChildAnimations(options.delay)]);
|
|
4319
|
-
}
|
|
4320
|
-
}
|
|
4321
|
-
function animateChildren(visualElement, variant, delay = 0, delayChildren = 0, staggerChildren = 0, staggerDirection = 1, options) {
|
|
4322
|
-
const animations = [];
|
|
4323
|
-
for (const child of visualElement.variantChildren) {
|
|
4324
|
-
child.notify("AnimationStart", variant);
|
|
4325
|
-
animations.push(animateVariant(child, variant, {
|
|
4326
|
-
...options,
|
|
4327
|
-
delay: delay +
|
|
4328
|
-
(typeof delayChildren === "function" ? 0 : delayChildren) +
|
|
4329
|
-
calcChildStagger(visualElement.variantChildren, child, delayChildren, staggerChildren, staggerDirection),
|
|
4330
|
-
}).then(() => child.notify("AnimationComplete", variant)));
|
|
4331
|
-
}
|
|
4332
|
-
return Promise.all(animations);
|
|
4302
|
+
return when
|
|
4303
|
+
? when === "beforeChildren"
|
|
4304
|
+
? getAnimation().then(() => getChildAnimations())
|
|
4305
|
+
: getChildAnimations().then(getAnimation)
|
|
4306
|
+
: Promise.all([getAnimation(), getChildAnimations(options.delay)]);
|
|
4333
4307
|
}
|
|
4334
4308
|
|
|
4335
4309
|
function animateVisualElement(visualElement, definition, options = {}) {
|
|
4336
4310
|
visualElement.notify("AnimationStart", definition);
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
else if (typeof definition === "string") {
|
|
4343
|
-
animation = animateVariant(visualElement, definition, options);
|
|
4344
|
-
}
|
|
4345
|
-
else {
|
|
4346
|
-
const resolvedDefinition = typeof definition === "function"
|
|
4347
|
-
? resolveVariant(visualElement, definition, options.custom)
|
|
4348
|
-
: definition;
|
|
4349
|
-
animation = Promise.all(animateTarget(visualElement, resolvedDefinition, options));
|
|
4350
|
-
}
|
|
4311
|
+
const animation = Array.isArray(definition)
|
|
4312
|
+
? Promise.all(definition.map((variant) => animateVariant(visualElement, variant, options)))
|
|
4313
|
+
: typeof definition === "string"
|
|
4314
|
+
? animateVariant(visualElement, definition, options)
|
|
4315
|
+
: Promise.all(animateTarget(visualElement, resolveVariant(visualElement, definition, options.custom), options));
|
|
4351
4316
|
return animation.then(() => {
|
|
4352
4317
|
visualElement.notify("AnimationComplete", definition);
|
|
4353
4318
|
});
|
|
@@ -4873,7 +4838,12 @@
|
|
|
4873
4838
|
const onRemove = () => {
|
|
4874
4839
|
cancelOnChange();
|
|
4875
4840
|
render && !computed && this.cancel(render);
|
|
4876
|
-
|
|
4841
|
+
/**
|
|
4842
|
+
* A later set() of the same name has already removed this
|
|
4843
|
+
* entry, so leave the one that replaced it.
|
|
4844
|
+
*/
|
|
4845
|
+
this.values.get(name)?.onRemove === onRemove &&
|
|
4846
|
+
this.values.delete(name);
|
|
4877
4847
|
};
|
|
4878
4848
|
this.values.set(name, {
|
|
4879
4849
|
value,
|
|
@@ -5352,24 +5322,35 @@
|
|
|
5352
5322
|
else if (key.startsWith("attr")) {
|
|
5353
5323
|
return addAttrValue(element, state, key, value, convertAttrKey(key));
|
|
5354
5324
|
}
|
|
5355
|
-
|
|
5325
|
+
/**
|
|
5326
|
+
* Transforms and origins aren't CSS properties (bar `x`/`y` in some
|
|
5327
|
+
* browsers), so check them by name rather than `key in element.style`.
|
|
5328
|
+
*/
|
|
5329
|
+
const handler = transformProps.has(key) ||
|
|
5330
|
+
originProps.has(key) ||
|
|
5331
|
+
isCSSVar(key) ||
|
|
5332
|
+
key in element.style
|
|
5333
|
+
? addStyleValue
|
|
5334
|
+
: addAttrValue;
|
|
5356
5335
|
return handler(element, state, key, value);
|
|
5357
5336
|
};
|
|
5358
5337
|
/**
|
|
5359
5338
|
* Reads the current value of `key` from an SVG element as the origin of
|
|
5360
5339
|
* an animation, as the SVG VisualElement does: transforms start from
|
|
5361
5340
|
* their defaults, CSS variables and the few CSS-only properties come from
|
|
5362
|
-
* computed style
|
|
5363
|
-
* and everything else is read from the
|
|
5364
|
-
* (`strokeWidth` -> `stroke-width`) or, failing
|
|
5365
|
-
* (`baseFrequency`).
|
|
5341
|
+
* computed style, falling back to the attribute when that's empty (e.g.
|
|
5342
|
+
* the element isn't rendered), and everything else is read from the
|
|
5343
|
+
* attribute, dash-cased (`strokeWidth` -> `stroke-width`) or, failing
|
|
5344
|
+
* that, as written (`baseFrequency`).
|
|
5366
5345
|
*/
|
|
5367
5346
|
const readSVGValue = (element, key) => {
|
|
5368
5347
|
if (transformProps.has(key)) {
|
|
5369
5348
|
return numberValueTypes[key]?.default || 0;
|
|
5370
5349
|
}
|
|
5371
5350
|
if (isCSSVar(key) || cssStyleProperties.includes(key)) {
|
|
5372
|
-
return readStyleValue(element, key)
|
|
5351
|
+
return (readStyleValue(element, key) ||
|
|
5352
|
+
element.getAttribute(camelToDash(key)) ||
|
|
5353
|
+
0);
|
|
5373
5354
|
}
|
|
5374
5355
|
key = convertAttrKey(key);
|
|
5375
5356
|
return (element.getAttribute(camelToDash(key)) ??
|
|
@@ -6072,6 +6053,25 @@
|
|
|
6072
6053
|
return typeof a === "function" ? resizeWindow(a) : resizeElement(a, b);
|
|
6073
6054
|
}
|
|
6074
6055
|
|
|
6056
|
+
/**
|
|
6057
|
+
* @deprecated Kept because framer-motion 13.0–13.4 import it from
|
|
6058
|
+
* motion-dom with a ^ range. Removed in v14.
|
|
6059
|
+
*/
|
|
6060
|
+
function observeTimeline(update, timeline) {
|
|
6061
|
+
let prevProgress;
|
|
6062
|
+
const onFrame = () => {
|
|
6063
|
+
const { currentTime } = timeline;
|
|
6064
|
+
const percentage = currentTime === null ? 0 : currentTime.value;
|
|
6065
|
+
const progress = percentage / 100;
|
|
6066
|
+
if (prevProgress !== progress) {
|
|
6067
|
+
update(progress);
|
|
6068
|
+
}
|
|
6069
|
+
prevProgress = progress;
|
|
6070
|
+
};
|
|
6071
|
+
frame.preUpdate(onFrame, true);
|
|
6072
|
+
return () => cancelFrame(onFrame);
|
|
6073
|
+
}
|
|
6074
|
+
|
|
6075
6075
|
const statsBuffer = {
|
|
6076
6076
|
value: null,
|
|
6077
6077
|
addProjectionMetrics: null,
|
|
@@ -7954,8 +7954,20 @@
|
|
|
7954
7954
|
if (this.projection && !this.projection.instance) {
|
|
7955
7955
|
this.projection.mount(instance);
|
|
7956
7956
|
}
|
|
7957
|
-
|
|
7958
|
-
|
|
7957
|
+
/**
|
|
7958
|
+
* Join the closest variant node above, so its variant changes
|
|
7959
|
+
* propagate here, unless inherit={false} cuts the chain.
|
|
7960
|
+
*/
|
|
7961
|
+
if (this.isVariantNode && !this.isControllingVariants) {
|
|
7962
|
+
let node = this;
|
|
7963
|
+
do
|
|
7964
|
+
node = node.props.inherit !== false && node.parent;
|
|
7965
|
+
while (node && !node.isVariantNode);
|
|
7966
|
+
if (node) {
|
|
7967
|
+
const { variantChildren } = node;
|
|
7968
|
+
variantChildren.add(this);
|
|
7969
|
+
this.removeFromVariantTree = () => variantChildren.delete(this);
|
|
7970
|
+
}
|
|
7959
7971
|
}
|
|
7960
7972
|
this.values.forEach((value, key) => this.bindToMotionValue(key, value));
|
|
7961
7973
|
/**
|
|
@@ -8065,9 +8077,11 @@
|
|
|
8065
8077
|
}
|
|
8066
8078
|
sortNodePosition(other) {
|
|
8067
8079
|
/**
|
|
8068
|
-
* If
|
|
8080
|
+
* If either node isn't mounted, or they aren't even of the same type,
|
|
8081
|
+
* we can't compare their document order.
|
|
8069
8082
|
*/
|
|
8070
8083
|
if (!this.current ||
|
|
8084
|
+
!other.current ||
|
|
8071
8085
|
!this.sortInstanceNodePosition ||
|
|
8072
8086
|
this.type !== other.type) {
|
|
8073
8087
|
return 0;
|
|
@@ -8173,24 +8187,6 @@
|
|
|
8173
8187
|
getTransformPagePoint() {
|
|
8174
8188
|
return this.props.transformPagePoint;
|
|
8175
8189
|
}
|
|
8176
|
-
getClosestVariantNode() {
|
|
8177
|
-
return this.isVariantNode
|
|
8178
|
-
? this
|
|
8179
|
-
: this.parent
|
|
8180
|
-
? this.parent.getClosestVariantNode()
|
|
8181
|
-
: undefined;
|
|
8182
|
-
}
|
|
8183
|
-
/**
|
|
8184
|
-
* Add a child visual element to our set of children.
|
|
8185
|
-
*/
|
|
8186
|
-
addVariantChild(child) {
|
|
8187
|
-
const closestVariantNode = this.getClosestVariantNode();
|
|
8188
|
-
if (closestVariantNode) {
|
|
8189
|
-
closestVariantNode.variantChildren &&
|
|
8190
|
-
closestVariantNode.variantChildren.add(child);
|
|
8191
|
-
return () => closestVariantNode.variantChildren.delete(child);
|
|
8192
|
-
}
|
|
8193
|
-
}
|
|
8194
8190
|
/**
|
|
8195
8191
|
* Add a motion value and bind it to this visual element.
|
|
8196
8192
|
*/
|
|
@@ -8285,41 +8281,6 @@
|
|
|
8285
8281
|
setBaseTarget(key, value) {
|
|
8286
8282
|
this.baseTarget[key] = value;
|
|
8287
8283
|
}
|
|
8288
|
-
/**
|
|
8289
|
-
* Find the base target for a value thats been removed from all animation
|
|
8290
|
-
* props.
|
|
8291
|
-
*/
|
|
8292
|
-
getBaseTarget(key) {
|
|
8293
|
-
const { initial } = this.props;
|
|
8294
|
-
let valueFromInitial;
|
|
8295
|
-
if (typeof initial === "string" || typeof initial === "object") {
|
|
8296
|
-
const variant = resolveVariantFromProps(this.props, initial, this.presenceContext?.custom);
|
|
8297
|
-
if (variant) {
|
|
8298
|
-
valueFromInitial = variant[key];
|
|
8299
|
-
}
|
|
8300
|
-
}
|
|
8301
|
-
/**
|
|
8302
|
-
* If this value still exists in the current initial variant, read that.
|
|
8303
|
-
*/
|
|
8304
|
-
if (initial && valueFromInitial !== undefined) {
|
|
8305
|
-
return valueFromInitial;
|
|
8306
|
-
}
|
|
8307
|
-
/**
|
|
8308
|
-
* Alternatively, if this VisualElement config has defined a getBaseTarget
|
|
8309
|
-
* so we can read the value from an alternative source, try that.
|
|
8310
|
-
*/
|
|
8311
|
-
const target = this.getBaseTargetFromProps(this.props, key);
|
|
8312
|
-
if (target !== undefined && !isMotionValue(target))
|
|
8313
|
-
return target;
|
|
8314
|
-
/**
|
|
8315
|
-
* If the value was initially defined on initial, but it doesn't any more,
|
|
8316
|
-
* return undefined. Otherwise return the value as initially read from the DOM.
|
|
8317
|
-
*/
|
|
8318
|
-
return this.initialValues[key] !== undefined &&
|
|
8319
|
-
valueFromInitial === undefined
|
|
8320
|
-
? undefined
|
|
8321
|
-
: this.baseTarget[key];
|
|
8322
|
-
}
|
|
8323
8284
|
on(eventName, callback) {
|
|
8324
8285
|
if (!this.events[eventName]) {
|
|
8325
8286
|
this.events[eventName] = new motionUtils.SubscriptionManager();
|
|
@@ -8624,34 +8585,6 @@
|
|
|
8624
8585
|
}
|
|
8625
8586
|
}
|
|
8626
8587
|
|
|
8627
|
-
const numVariantProps = variantProps.length;
|
|
8628
|
-
/**
|
|
8629
|
-
* Get variant context from a visual element's parent chain.
|
|
8630
|
-
* Uses `any` type for visualElement to avoid circular dependencies.
|
|
8631
|
-
*/
|
|
8632
|
-
function getVariantContext(visualElement) {
|
|
8633
|
-
if (!visualElement)
|
|
8634
|
-
return undefined;
|
|
8635
|
-
if (!visualElement.isControllingVariants) {
|
|
8636
|
-
const context = visualElement.parent
|
|
8637
|
-
? getVariantContext(visualElement.parent) || {}
|
|
8638
|
-
: {};
|
|
8639
|
-
if (visualElement.props.initial !== undefined) {
|
|
8640
|
-
context.initial = visualElement.props.initial;
|
|
8641
|
-
}
|
|
8642
|
-
return context;
|
|
8643
|
-
}
|
|
8644
|
-
const context = {};
|
|
8645
|
-
for (let i = 0; i < numVariantProps; i++) {
|
|
8646
|
-
const name = variantProps[i];
|
|
8647
|
-
const prop = visualElement.props[name];
|
|
8648
|
-
if (isVariantLabel(prop) || prop === false) {
|
|
8649
|
-
context[name] = prop;
|
|
8650
|
-
}
|
|
8651
|
-
}
|
|
8652
|
-
return context;
|
|
8653
|
-
}
|
|
8654
|
-
|
|
8655
8588
|
function shallowCompare(next, prev) {
|
|
8656
8589
|
if (!Array.isArray(prev))
|
|
8657
8590
|
return false;
|
|
@@ -8666,332 +8599,211 @@
|
|
|
8666
8599
|
}
|
|
8667
8600
|
|
|
8668
8601
|
const reversePriorityOrder = [...variantPriorityOrder].reverse();
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
|
-
|
|
8602
|
+
/**
|
|
8603
|
+
* Diffs the element's animation props (one layer per AnimationType, highest
|
|
8604
|
+
* priority wins each value) against the previous call and starts animations
|
|
8605
|
+
* for what changed.
|
|
8606
|
+
*
|
|
8607
|
+
* Uses `any` type for visualElement to avoid circular dependencies. It reads
|
|
8608
|
+
* props, parent, presenceContext, variantChildren, enteringChildren,
|
|
8609
|
+
* manuallyAnimateOnMount, blockInitialAnimation, getValue(),
|
|
8610
|
+
* getBaseTargetFromProps(), baseTarget and initialValues.
|
|
8611
|
+
*/
|
|
8675
8612
|
function createAnimationState(visualElement) {
|
|
8676
|
-
let animate =
|
|
8613
|
+
let animate = (animations) => Promise.all(animations.map(({ animation, options }) => animateVisualElement(visualElement, animation, options)));
|
|
8677
8614
|
let state = createState();
|
|
8678
8615
|
let isInitialRender = true;
|
|
8679
8616
|
/**
|
|
8680
|
-
*
|
|
8681
|
-
*
|
|
8682
|
-
* animateChanges() call after a reset we need to behave like the initial
|
|
8683
|
-
* render for variant-inheritance checks, even though isInitialRender is
|
|
8684
|
-
* already false.
|
|
8617
|
+
* After a reset (StrictMode, Suspense, AnimatePresence re-entry) the next
|
|
8618
|
+
* animateChanges() mounts again, but initial={false} no longer applies.
|
|
8685
8619
|
*/
|
|
8686
8620
|
let wasReset = false;
|
|
8687
|
-
/**
|
|
8688
|
-
* This function will be used to reduce the animation definitions for
|
|
8689
|
-
* each active animation type into an object of resolved values for it.
|
|
8690
|
-
*/
|
|
8691
|
-
const buildResolvedTypeValues = (type) => (acc, definition) => {
|
|
8692
|
-
const resolved = resolveVariant(visualElement, definition, type === "exit"
|
|
8693
|
-
? visualElement.presenceContext?.custom
|
|
8694
|
-
: undefined);
|
|
8695
|
-
if (resolved) {
|
|
8696
|
-
const { transition, transitionEnd, ...target } = resolved;
|
|
8697
|
-
acc = { ...acc, ...target, ...transitionEnd };
|
|
8698
|
-
}
|
|
8699
|
-
return acc;
|
|
8700
|
-
};
|
|
8701
|
-
/**
|
|
8702
|
-
* This just allows us to inject mocked animation functions
|
|
8703
|
-
* @internal
|
|
8704
|
-
*/
|
|
8705
|
-
function setAnimateFunction(makeAnimator) {
|
|
8706
|
-
animate = makeAnimator(visualElement);
|
|
8707
|
-
}
|
|
8708
|
-
/**
|
|
8709
|
-
* When we receive new props, we need to:
|
|
8710
|
-
* 1. Create a list of protected keys for each type. This is a directory of
|
|
8711
|
-
* value keys that are currently being "handled" by types of a higher priority
|
|
8712
|
-
* so that whenever an animation is played of a given type, these values are
|
|
8713
|
-
* protected from being animated.
|
|
8714
|
-
* 2. Determine if an animation type needs animating.
|
|
8715
|
-
* 3. Determine if any values have been removed from a type and figure out
|
|
8716
|
-
* what to animate those to.
|
|
8717
|
-
*/
|
|
8718
8621
|
function animateChanges(changedActiveType) {
|
|
8719
|
-
const { props } = visualElement;
|
|
8720
|
-
const
|
|
8721
|
-
/**
|
|
8722
|
-
* A list of animations that we'll build into as we iterate through the animation
|
|
8723
|
-
* types. This will get executed at the end of the function.
|
|
8724
|
-
*/
|
|
8622
|
+
const { props, parent, manuallyAnimateOnMount } = visualElement;
|
|
8623
|
+
const isMounting = isInitialRender || wasReset;
|
|
8725
8624
|
const animations = [];
|
|
8726
8625
|
/**
|
|
8727
|
-
*
|
|
8728
|
-
*
|
|
8626
|
+
* Values removed from a type. A lower-priority type that defines
|
|
8627
|
+
* them animates them back, otherwise they fall back to a base target.
|
|
8729
8628
|
*/
|
|
8730
8629
|
const removedKeys = new Set();
|
|
8731
8630
|
/**
|
|
8732
|
-
*
|
|
8733
|
-
* copy it without iteration. Each time we hit an animation type we set its protected
|
|
8734
|
-
* keys - the keys its not allowed to animate - to the latest version of this object.
|
|
8631
|
+
* Values claimed by active, higher-priority types.
|
|
8735
8632
|
*/
|
|
8736
8633
|
let encounteredKeys = {};
|
|
8737
8634
|
/**
|
|
8738
|
-
*
|
|
8739
|
-
*
|
|
8635
|
+
* Once a type has been deactivated, lower-priority variant labels
|
|
8636
|
+
* re-animate so variant children animate back too.
|
|
8740
8637
|
*/
|
|
8741
8638
|
let removedVariantIndex = Infinity;
|
|
8742
8639
|
/**
|
|
8743
|
-
*
|
|
8744
|
-
*
|
|
8745
|
-
* need to be animated). If any values have been removed, we want to detect those in
|
|
8746
|
-
* lower priority props and flag for animation.
|
|
8640
|
+
* Variant labels are inherited from the closest variant-controlling
|
|
8641
|
+
* ancestor, unless an element on the way has inherit={false}.
|
|
8747
8642
|
*/
|
|
8748
|
-
|
|
8749
|
-
|
|
8643
|
+
let source = visualElement;
|
|
8644
|
+
do
|
|
8645
|
+
source = source.props.inherit !== false && source.parent;
|
|
8646
|
+
while (source && !source.isControllingVariants);
|
|
8647
|
+
reversePriorityOrder.forEach((type, i) => {
|
|
8750
8648
|
const typeState = state[type];
|
|
8751
|
-
const
|
|
8752
|
-
|
|
8753
|
-
|
|
8649
|
+
const ownProp = props[type];
|
|
8650
|
+
const inheritedProp = source && source.props[type];
|
|
8651
|
+
const prop = ownProp !== undefined
|
|
8652
|
+
? ownProp
|
|
8653
|
+
: isVariantLabel(inheritedProp) || inheritedProp === false
|
|
8654
|
+
? inheritedProp
|
|
8655
|
+
: undefined;
|
|
8754
8656
|
const propIsVariant = isVariantLabel(prop);
|
|
8755
|
-
/**
|
|
8756
|
-
* If this type has *just* changed isActive status, set activeDelta
|
|
8757
|
-
* to that status. Otherwise set to null.
|
|
8758
|
-
*/
|
|
8759
8657
|
const activeDelta = type === changedActiveType ? typeState.isActive : null;
|
|
8760
8658
|
if (activeDelta === false)
|
|
8761
8659
|
removedVariantIndex = i;
|
|
8762
8660
|
/**
|
|
8763
|
-
*
|
|
8764
|
-
*
|
|
8765
|
-
*
|
|
8766
|
-
* TODO: Can probably change this to a !isControllingVariants check
|
|
8767
|
-
*/
|
|
8768
|
-
let isInherited = prop === context[type] &&
|
|
8769
|
-
prop !== props[type] &&
|
|
8770
|
-
propIsVariant;
|
|
8771
|
-
if (isInherited &&
|
|
8772
|
-
(isInitialRender || wasReset) &&
|
|
8773
|
-
visualElement.manuallyAnimateOnMount) {
|
|
8774
|
-
isInherited = false;
|
|
8775
|
-
}
|
|
8776
|
-
/**
|
|
8777
|
-
* Set all encountered keys so far as the protected keys for this type. This will
|
|
8778
|
-
* be any key that has been animated or otherwise handled by active, higher-priority types.
|
|
8661
|
+
* Inherited labels are animated by the parent through
|
|
8662
|
+
* variantChildren, unless this element mounted after its parent.
|
|
8779
8663
|
*/
|
|
8664
|
+
const isInherited = propIsVariant &&
|
|
8665
|
+
ownProp === undefined &&
|
|
8666
|
+
!(isMounting && manuallyAnimateOnMount);
|
|
8780
8667
|
typeState.protectedKeys = { ...encounteredKeys };
|
|
8781
|
-
|
|
8782
|
-
if (
|
|
8783
|
-
// If it isn't active and hasn't *just* been set as inactive
|
|
8784
|
-
(!typeState.isActive && activeDelta === null) ||
|
|
8785
|
-
// If we didn't and don't have any defined prop for this animation type
|
|
8668
|
+
if ((!typeState.isActive && activeDelta === null) ||
|
|
8786
8669
|
(!prop && !typeState.prevProp) ||
|
|
8787
|
-
// Or if the prop doesn't define an animation
|
|
8788
8670
|
isAnimationControls(prop) ||
|
|
8789
8671
|
typeof prop === "boolean") {
|
|
8790
|
-
|
|
8672
|
+
return;
|
|
8791
8673
|
}
|
|
8792
8674
|
/**
|
|
8793
|
-
*
|
|
8794
|
-
*
|
|
8795
|
-
*
|
|
8796
|
-
* value animations that stop the originals, leaving the exit
|
|
8797
|
-
* animation promise unresolved and the component stuck in the DOM.
|
|
8675
|
+
* Don't re-resolve a running exit: a changed custom would start
|
|
8676
|
+
* new value animations that stop the originals, leaving the exit
|
|
8677
|
+
* promise unresolved and the element stuck in the DOM.
|
|
8798
8678
|
*/
|
|
8799
8679
|
if (type === "exit" && typeState.isActive && activeDelta !== true) {
|
|
8800
|
-
|
|
8801
|
-
encounteredKeys
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
}
|
|
8806
|
-
continue;
|
|
8680
|
+
encounteredKeys = {
|
|
8681
|
+
...encounteredKeys,
|
|
8682
|
+
...typeState.prevResolvedValues,
|
|
8683
|
+
};
|
|
8684
|
+
return;
|
|
8807
8685
|
}
|
|
8808
|
-
/**
|
|
8809
|
-
* As we go look through the values defined on this type, if we detect
|
|
8810
|
-
* a changed value or a value that was removed in a higher priority, we set
|
|
8811
|
-
* this to true and add this prop to the animation list.
|
|
8812
|
-
*/
|
|
8813
8686
|
const variantDidChange = checkVariantsDidChange(typeState.prevProp, prop);
|
|
8814
8687
|
let shouldAnimateType = variantDidChange ||
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
typeState.isActive &&
|
|
8818
|
-
!isInherited &&
|
|
8819
|
-
propIsVariant) ||
|
|
8820
|
-
// If we removed a higher-priority variant (i is in reverse order)
|
|
8821
|
-
(i > removedVariantIndex && propIsVariant);
|
|
8688
|
+
(propIsVariant &&
|
|
8689
|
+
((activeDelta && !isInherited) || i > removedVariantIndex));
|
|
8822
8690
|
let handledRemovedValues = false;
|
|
8823
|
-
/**
|
|
8824
|
-
* As animations can be set as variant lists, variants or target objects, we
|
|
8825
|
-
* coerce everything to an array if it isn't one already
|
|
8826
|
-
*/
|
|
8827
8691
|
const definitionList = Array.isArray(prop) ? prop : [prop];
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
|
|
8831
|
-
|
|
8832
|
-
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
|
|
8837
|
-
* and decide:
|
|
8838
|
-
* 1. If the value has changed, and needs animating
|
|
8839
|
-
* 2. If it has been removed, and needs adding to the removedKeys set
|
|
8840
|
-
* 3. If it has been removed in a higher priority type and needs animating
|
|
8841
|
-
* 4. If it hasn't been removed in a higher priority but hasn't changed, and
|
|
8842
|
-
* needs adding to the type's protectedKeys list.
|
|
8843
|
-
*/
|
|
8844
|
-
const { prevResolvedValues = {} } = typeState;
|
|
8845
|
-
const allKeys = {
|
|
8846
|
-
...prevResolvedValues,
|
|
8847
|
-
...resolvedValues,
|
|
8848
|
-
};
|
|
8849
|
-
const markToAnimate = (key) => {
|
|
8850
|
-
shouldAnimateType = true;
|
|
8851
|
-
if (removedKeys.has(key)) {
|
|
8852
|
-
handledRemovedValues = true;
|
|
8853
|
-
removedKeys.delete(key);
|
|
8692
|
+
let resolvedValues = {};
|
|
8693
|
+
if (activeDelta !== false) {
|
|
8694
|
+
for (const definition of definitionList) {
|
|
8695
|
+
const { transition, transitionEnd, ...target } = resolveVariant(visualElement, definition, getTypeCustom(visualElement, type)) || {};
|
|
8696
|
+
resolvedValues = {
|
|
8697
|
+
...resolvedValues,
|
|
8698
|
+
...target,
|
|
8699
|
+
...transitionEnd,
|
|
8700
|
+
};
|
|
8854
8701
|
}
|
|
8855
|
-
|
|
8856
|
-
|
|
8857
|
-
|
|
8858
|
-
|
|
8859
|
-
|
|
8860
|
-
for (const key in allKeys) {
|
|
8702
|
+
}
|
|
8703
|
+
const { prevResolvedValues } = typeState;
|
|
8704
|
+
for (const key in { ...prevResolvedValues, ...resolvedValues }) {
|
|
8705
|
+
if (key in encounteredKeys)
|
|
8706
|
+
continue;
|
|
8861
8707
|
const next = resolvedValues[key];
|
|
8862
8708
|
const prev = prevResolvedValues[key];
|
|
8863
|
-
// If we've already handled this we can just skip ahead
|
|
8864
|
-
if (encounteredKeys.hasOwnProperty(key))
|
|
8865
|
-
continue;
|
|
8866
8709
|
/**
|
|
8867
|
-
*
|
|
8710
|
+
* Keyframes compare by value, but replay whenever the
|
|
8711
|
+
* variant label changed.
|
|
8868
8712
|
*/
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
8713
|
+
const valueHasChanged = Array.isArray(next) && Array.isArray(prev)
|
|
8714
|
+
? !shallowCompare(next, prev) || variantDidChange
|
|
8715
|
+
: next !== prev;
|
|
8716
|
+
if (valueHasChanged &&
|
|
8717
|
+
(next === undefined || next === null)) {
|
|
8718
|
+
removedKeys.add(key);
|
|
8873
8719
|
}
|
|
8874
|
-
else
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
8883
|
-
// If it's undefined, it's been removed.
|
|
8884
|
-
removedKeys.add(key);
|
|
8885
|
-
}
|
|
8886
|
-
}
|
|
8887
|
-
else if (next !== undefined && removedKeys.has(key)) {
|
|
8888
|
-
/**
|
|
8889
|
-
* If next hasn't changed and it isn't undefined, we want to check if it's
|
|
8890
|
-
* been removed by a higher priority
|
|
8891
|
-
*/
|
|
8892
|
-
markToAnimate(key);
|
|
8720
|
+
else if (valueHasChanged ||
|
|
8721
|
+
(next !== undefined && removedKeys.has(key))) {
|
|
8722
|
+
shouldAnimateType = true;
|
|
8723
|
+
if (removedKeys.delete(key))
|
|
8724
|
+
handledRemovedValues = true;
|
|
8725
|
+
typeState.needsAnimating[key] = true;
|
|
8726
|
+
const motionValue = visualElement.getValue(key);
|
|
8727
|
+
if (motionValue)
|
|
8728
|
+
motionValue.liveStyle = false;
|
|
8893
8729
|
}
|
|
8894
8730
|
else {
|
|
8895
|
-
/**
|
|
8896
|
-
* If it hasn't changed, we add it to the list of protected values
|
|
8897
|
-
* to ensure it doesn't get animated.
|
|
8898
|
-
*/
|
|
8899
8731
|
typeState.protectedKeys[key] = true;
|
|
8900
8732
|
}
|
|
8901
8733
|
}
|
|
8902
|
-
/**
|
|
8903
|
-
* Update the typeState so next time animateChanges is called we can compare the
|
|
8904
|
-
* latest prop and resolvedValues to these.
|
|
8905
|
-
*/
|
|
8906
8734
|
typeState.prevProp = prop;
|
|
8907
8735
|
typeState.prevResolvedValues = resolvedValues;
|
|
8908
8736
|
if (typeState.isActive) {
|
|
8909
8737
|
encounteredKeys = { ...encounteredKeys, ...resolvedValues };
|
|
8910
8738
|
}
|
|
8911
|
-
if (
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
}
|
|
8915
|
-
/**
|
|
8916
|
-
* If this is an inherited prop we want to skip this animation
|
|
8917
|
-
* unless the inherited variants haven't changed on this render.
|
|
8918
|
-
*/
|
|
8919
|
-
const willAnimateViaParent = isInherited && variantDidChange;
|
|
8920
|
-
const needsAnimating = !willAnimateViaParent || handledRemovedValues;
|
|
8921
|
-
if (shouldAnimateType && needsAnimating) {
|
|
8922
|
-
animations.push(...definitionList.map((animation) => {
|
|
8739
|
+
if (shouldAnimateType &&
|
|
8740
|
+
(!(isInherited && variantDidChange) || handledRemovedValues)) {
|
|
8741
|
+
for (const animation of definitionList) {
|
|
8923
8742
|
const options = { type };
|
|
8924
8743
|
/**
|
|
8925
|
-
*
|
|
8926
|
-
*
|
|
8927
|
-
*
|
|
8744
|
+
* Elements that mount into an already-mounted parent
|
|
8745
|
+
* animate themselves, staggered by the parent variant's
|
|
8746
|
+
* delayChildren.
|
|
8928
8747
|
*/
|
|
8929
8748
|
if (typeof animation === "string" &&
|
|
8930
|
-
|
|
8931
|
-
|
|
8932
|
-
|
|
8933
|
-
|
|
8934
|
-
|
|
8935
|
-
|
|
8936
|
-
if (parent.enteringChildren && parentVariant) {
|
|
8937
|
-
const { delayChildren } = parentVariant.transition || {};
|
|
8938
|
-
options.delay = calcChildStagger(parent.enteringChildren, visualElement, delayChildren);
|
|
8939
|
-
}
|
|
8749
|
+
isMounting &&
|
|
8750
|
+
manuallyAnimateOnMount &&
|
|
8751
|
+
parent?.enteringChildren) {
|
|
8752
|
+
const delayChildren = resolveVariant(parent, animation)
|
|
8753
|
+
?.transition?.delayChildren;
|
|
8754
|
+
options.delay = calcChildStagger(parent.enteringChildren, visualElement, delayChildren);
|
|
8940
8755
|
}
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
options,
|
|
8944
|
-
};
|
|
8945
|
-
}));
|
|
8756
|
+
animations.push({ animation, options });
|
|
8757
|
+
}
|
|
8946
8758
|
}
|
|
8947
|
-
}
|
|
8759
|
+
});
|
|
8948
8760
|
/**
|
|
8949
|
-
*
|
|
8950
|
-
*
|
|
8951
|
-
*
|
|
8761
|
+
* Removed values that no lower-priority type defines animate back to
|
|
8762
|
+
* initial, then style, then the value as first read. If initial no
|
|
8763
|
+
* longer defines a value it once did, it stays where it is.
|
|
8952
8764
|
*/
|
|
8953
8765
|
if (removedKeys.size) {
|
|
8766
|
+
const { initial } = props;
|
|
8954
8767
|
const fallbackAnimation = {};
|
|
8955
|
-
|
|
8956
|
-
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
if (typeof props.initial !== "boolean") {
|
|
8960
|
-
const initialTransition = resolveVariant(visualElement, Array.isArray(props.initial)
|
|
8961
|
-
? props.initial[0]
|
|
8962
|
-
: props.initial);
|
|
8963
|
-
if (initialTransition && initialTransition.transition) {
|
|
8964
|
-
fallbackAnimation.transition = initialTransition.transition;
|
|
8965
|
-
}
|
|
8768
|
+
const resolvedInitial = typeof initial !== "boolean" &&
|
|
8769
|
+
resolveVariant(visualElement, Array.isArray(initial) ? initial[0] : initial, visualElement.presenceContext?.custom);
|
|
8770
|
+
if (resolvedInitial && resolvedInitial.transition) {
|
|
8771
|
+
fallbackAnimation.transition = resolvedInitial.transition;
|
|
8966
8772
|
}
|
|
8967
8773
|
removedKeys.forEach((key) => {
|
|
8968
|
-
const fallbackTarget = visualElement.getBaseTarget(key);
|
|
8969
8774
|
const motionValue = visualElement.getValue(key);
|
|
8970
8775
|
if (motionValue)
|
|
8971
8776
|
motionValue.liveStyle = true;
|
|
8972
|
-
|
|
8973
|
-
|
|
8777
|
+
const fromInitial = resolvedInitial && !Array.isArray(initial)
|
|
8778
|
+
? resolvedInitial[key]
|
|
8779
|
+
: undefined;
|
|
8780
|
+
const fromProps = visualElement.getBaseTargetFromProps(props, key);
|
|
8781
|
+
fallbackAnimation[key] =
|
|
8782
|
+
(fromInitial !== undefined
|
|
8783
|
+
? fromInitial
|
|
8784
|
+
: fromProps !== undefined && !isMotionValue(fromProps)
|
|
8785
|
+
? fromProps
|
|
8786
|
+
: visualElement.initialValues[key] === undefined
|
|
8787
|
+
? visualElement.baseTarget[key]
|
|
8788
|
+
: undefined) ?? null;
|
|
8974
8789
|
});
|
|
8975
8790
|
animations.push({ animation: fallbackAnimation });
|
|
8976
8791
|
}
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
return shouldAnimate ? animate(animations) : Promise.resolve();
|
|
8792
|
+
const blockAnimation = (isMounting && visualElement.blockInitialAnimation) ||
|
|
8793
|
+
(isInitialRender &&
|
|
8794
|
+
!manuallyAnimateOnMount &&
|
|
8795
|
+
(props.initial === false || props.initial === props.animate));
|
|
8796
|
+
isInitialRender = wasReset = false;
|
|
8797
|
+
return !blockAnimation && animations.length
|
|
8798
|
+
? animate(animations)
|
|
8799
|
+
: Promise.resolve();
|
|
8986
8800
|
}
|
|
8987
8801
|
/**
|
|
8988
8802
|
* Change whether a certain animation type is active.
|
|
8989
8803
|
*/
|
|
8990
8804
|
function setActive(type, isActive) {
|
|
8991
|
-
// If the active state hasn't changed, we can safely do nothing here
|
|
8992
8805
|
if (state[type].isActive === isActive)
|
|
8993
8806
|
return Promise.resolve();
|
|
8994
|
-
// Propagate active change to children
|
|
8995
8807
|
visualElement.variantChildren?.forEach((child) => child.animationState?.setActive(type, isActive));
|
|
8996
8808
|
state[type].isActive = isActive;
|
|
8997
8809
|
const animations = animateChanges(type);
|
|
@@ -9003,7 +8815,13 @@
|
|
|
9003
8815
|
return {
|
|
9004
8816
|
animateChanges,
|
|
9005
8817
|
setActive,
|
|
9006
|
-
|
|
8818
|
+
/**
|
|
8819
|
+
* Allows tests to inject a mocked animate function.
|
|
8820
|
+
* @internal
|
|
8821
|
+
*/
|
|
8822
|
+
setAnimateFunction: (makeAnimator) => {
|
|
8823
|
+
animate = makeAnimator(visualElement);
|
|
8824
|
+
},
|
|
9007
8825
|
getState: () => state,
|
|
9008
8826
|
reset: () => {
|
|
9009
8827
|
state = createState();
|
|
@@ -9020,24 +8838,45 @@
|
|
|
9020
8838
|
}
|
|
9021
8839
|
return false;
|
|
9022
8840
|
}
|
|
9023
|
-
function createTypeState(isActive = false) {
|
|
9024
|
-
return {
|
|
9025
|
-
isActive,
|
|
9026
|
-
protectedKeys: {},
|
|
9027
|
-
needsAnimating: {},
|
|
9028
|
-
prevResolvedValues: {},
|
|
9029
|
-
};
|
|
9030
|
-
}
|
|
9031
8841
|
function createState() {
|
|
9032
|
-
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
}
|
|
8842
|
+
const state = {};
|
|
8843
|
+
for (const type of variantPriorityOrder) {
|
|
8844
|
+
state[type] = {
|
|
8845
|
+
isActive: type === "animate",
|
|
8846
|
+
protectedKeys: {},
|
|
8847
|
+
needsAnimating: {},
|
|
8848
|
+
prevResolvedValues: {},
|
|
8849
|
+
};
|
|
8850
|
+
}
|
|
8851
|
+
return state;
|
|
8852
|
+
}
|
|
8853
|
+
|
|
8854
|
+
const numVariantProps = variantProps.length;
|
|
8855
|
+
/**
|
|
8856
|
+
* Get variant context from a visual element's parent chain.
|
|
8857
|
+
* Uses `any` type for visualElement to avoid circular dependencies.
|
|
8858
|
+
*/
|
|
8859
|
+
function getVariantContext(visualElement) {
|
|
8860
|
+
if (!visualElement)
|
|
8861
|
+
return undefined;
|
|
8862
|
+
if (!visualElement.isControllingVariants) {
|
|
8863
|
+
const context = visualElement.parent
|
|
8864
|
+
? getVariantContext(visualElement.parent) || {}
|
|
8865
|
+
: {};
|
|
8866
|
+
if (visualElement.props.initial !== undefined) {
|
|
8867
|
+
context.initial = visualElement.props.initial;
|
|
8868
|
+
}
|
|
8869
|
+
return context;
|
|
8870
|
+
}
|
|
8871
|
+
const context = {};
|
|
8872
|
+
for (let i = 0; i < numVariantProps; i++) {
|
|
8873
|
+
const name = variantProps[i];
|
|
8874
|
+
const prop = visualElement.props[name];
|
|
8875
|
+
if (isVariantLabel(prop) || prop === false) {
|
|
8876
|
+
context[name] = prop;
|
|
8877
|
+
}
|
|
8878
|
+
}
|
|
8879
|
+
return context;
|
|
9041
8880
|
}
|
|
9042
8881
|
|
|
9043
8882
|
/**
|
|
@@ -11862,8 +11701,10 @@
|
|
|
11862
11701
|
exports.nodeGroup = nodeGroup;
|
|
11863
11702
|
exports.number = number;
|
|
11864
11703
|
exports.numberValueTypes = numberValueTypes;
|
|
11704
|
+
exports.observeTimeline = observeTimeline;
|
|
11865
11705
|
exports.optimizedAppearDataAttribute = optimizedAppearDataAttribute;
|
|
11866
11706
|
exports.optimizedAppearDataId = optimizedAppearDataId;
|
|
11707
|
+
exports.originProps = originProps;
|
|
11867
11708
|
exports.parseAnimateLayoutArgs = parseAnimateLayoutArgs;
|
|
11868
11709
|
exports.parseCSSVariable = parseCSSVariable;
|
|
11869
11710
|
exports.parseValueFromTransform = parseValueFromTransform;
|