motion-dom 12.33.0 → 12.33.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +42 -12
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/projection/shared/stack.mjs +26 -12
- package/dist/es/projection/shared/stack.mjs.map +1 -1
- package/dist/es/render/utils/animation-state.mjs +16 -0
- package/dist/es/render/utils/animation-state.mjs.map +1 -1
- package/dist/motion-dom.dev.js +42 -12
- package/dist/motion-dom.js +1 -1
- package/package.json +2 -2
|
@@ -6,6 +6,15 @@ class NodeStack {
|
|
|
6
6
|
}
|
|
7
7
|
add(node) {
|
|
8
8
|
addUniqueItem(this.members, node);
|
|
9
|
+
for (let i = this.members.length - 1; i >= 0; i--) {
|
|
10
|
+
const m = this.members[i];
|
|
11
|
+
if (m === node || m === this.lead || m === this.prevLead)
|
|
12
|
+
continue;
|
|
13
|
+
const inst = m.instance;
|
|
14
|
+
if (inst && inst.isConnected === false && m.isPresent !== false && !m.snapshot) {
|
|
15
|
+
removeItem(this.members, m);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
9
18
|
node.scheduleRender();
|
|
10
19
|
}
|
|
11
20
|
remove(node) {
|
|
@@ -30,7 +39,8 @@ class NodeStack {
|
|
|
30
39
|
let prevLead;
|
|
31
40
|
for (let i = indexOfNode; i >= 0; i--) {
|
|
32
41
|
const member = this.members[i];
|
|
33
|
-
|
|
42
|
+
const inst = member.instance;
|
|
43
|
+
if (member.isPresent !== false && (!inst || inst.isConnected !== false)) {
|
|
34
44
|
prevLead = member;
|
|
35
45
|
break;
|
|
36
46
|
}
|
|
@@ -65,17 +75,21 @@ class NodeStack {
|
|
|
65
75
|
nextDep !== undefined &&
|
|
66
76
|
prevDep === nextDep;
|
|
67
77
|
if (!dependencyMatches) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
const prevInstance = prevLead.instance;
|
|
79
|
+
const isStale = prevInstance && prevInstance.isConnected === false && !prevLead.snapshot;
|
|
80
|
+
if (!isStale) {
|
|
81
|
+
node.resumeFrom = prevLead;
|
|
82
|
+
if (preserveFollowOpacity) {
|
|
83
|
+
node.resumeFrom.preserveOpacity = true;
|
|
84
|
+
}
|
|
85
|
+
if (prevLead.snapshot) {
|
|
86
|
+
node.snapshot = prevLead.snapshot;
|
|
87
|
+
node.snapshot.latestValues =
|
|
88
|
+
prevLead.animationValues || prevLead.latestValues;
|
|
89
|
+
}
|
|
90
|
+
if (node.root && node.root.isUpdating) {
|
|
91
|
+
node.isLayoutDirty = true;
|
|
92
|
+
}
|
|
79
93
|
}
|
|
80
94
|
}
|
|
81
95
|
const { crossfade } = node.options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack.mjs","sources":["../../../../src/projection/shared/stack.ts"],"sourcesContent":["import { addUniqueItem, removeItem } from \"motion-utils\"\nimport { IProjectionNode } from \"../node/types\"\n\nexport class NodeStack {\n lead?: IProjectionNode\n prevLead?: IProjectionNode\n members: IProjectionNode[] = []\n\n add(node: IProjectionNode) {\n addUniqueItem(this.members, node)\n node.scheduleRender()\n }\n\n remove(node: IProjectionNode) {\n removeItem(this.members, node)\n if (node === this.prevLead) {\n this.prevLead = undefined\n }\n if (node === this.lead) {\n const prevLead = this.members[this.members.length - 1]\n if (prevLead) {\n this.promote(prevLead)\n }\n }\n }\n\n relegate(node: IProjectionNode): boolean {\n const indexOfNode = this.members.findIndex((member) => node === member)\n if (indexOfNode === 0) return false\n\n /**\n * Find the next projection node that is present\n */\n let prevLead: IProjectionNode | undefined\n for (let i = indexOfNode; i >= 0; i--) {\n const member = this.members[i]\n if (member.isPresent !== false) {\n prevLead = member\n break\n }\n }\n\n if (prevLead) {\n this.promote(prevLead)\n return true\n } else {\n return false\n }\n }\n\n promote(node: IProjectionNode, preserveFollowOpacity?: boolean) {\n const prevLead = this.lead\n\n if (node === prevLead) return\n\n this.prevLead = prevLead\n this.lead = node\n\n node.show()\n\n if (prevLead) {\n prevLead.instance && prevLead.scheduleRender()\n node.scheduleRender()\n\n /**\n * If both the new and previous lead have the same defined layoutDependency,\n * skip the shared layout animation. This allows components with layoutId\n * to opt-out of animations when their layoutDependency hasn't changed,\n * even when the component unmounts and remounts in a different location.\n */\n const prevDep = prevLead.options.layoutDependency\n const nextDep = node.options.layoutDependency\n const dependencyMatches =\n prevDep !== undefined &&\n nextDep !== undefined &&\n prevDep === nextDep\n\n if (!dependencyMatches) {\n node.resumeFrom = prevLead\n\n
|
|
1
|
+
{"version":3,"file":"stack.mjs","sources":["../../../../src/projection/shared/stack.ts"],"sourcesContent":["import { addUniqueItem, removeItem } from \"motion-utils\"\nimport { IProjectionNode } from \"../node/types\"\n\nexport class NodeStack {\n lead?: IProjectionNode\n prevLead?: IProjectionNode\n members: IProjectionNode[] = []\n\n add(node: IProjectionNode) {\n addUniqueItem(this.members, node)\n\n for (let i = this.members.length - 1; i >= 0; i--) {\n const m = this.members[i]\n if (m === node || m === this.lead || m === this.prevLead) continue\n const inst = m.instance as HTMLElement | undefined\n if (inst && inst.isConnected === false && m.isPresent !== false && !m.snapshot) {\n removeItem(this.members, m)\n }\n }\n\n node.scheduleRender()\n }\n\n remove(node: IProjectionNode) {\n removeItem(this.members, node)\n if (node === this.prevLead) {\n this.prevLead = undefined\n }\n if (node === this.lead) {\n const prevLead = this.members[this.members.length - 1]\n if (prevLead) {\n this.promote(prevLead)\n }\n }\n }\n\n relegate(node: IProjectionNode): boolean {\n const indexOfNode = this.members.findIndex((member) => node === member)\n if (indexOfNode === 0) return false\n\n /**\n * Find the next projection node that is present\n */\n let prevLead: IProjectionNode | undefined\n for (let i = indexOfNode; i >= 0; i--) {\n const member = this.members[i]\n const inst = member.instance as HTMLElement | undefined\n if (member.isPresent !== false && (!inst || inst.isConnected !== false)) {\n prevLead = member\n break\n }\n }\n\n if (prevLead) {\n this.promote(prevLead)\n return true\n } else {\n return false\n }\n }\n\n promote(node: IProjectionNode, preserveFollowOpacity?: boolean) {\n const prevLead = this.lead\n\n if (node === prevLead) return\n\n this.prevLead = prevLead\n this.lead = node\n\n node.show()\n\n if (prevLead) {\n prevLead.instance && prevLead.scheduleRender()\n node.scheduleRender()\n\n /**\n * If both the new and previous lead have the same defined layoutDependency,\n * skip the shared layout animation. This allows components with layoutId\n * to opt-out of animations when their layoutDependency hasn't changed,\n * even when the component unmounts and remounts in a different location.\n */\n const prevDep = prevLead.options.layoutDependency\n const nextDep = node.options.layoutDependency\n const dependencyMatches =\n prevDep !== undefined &&\n nextDep !== undefined &&\n prevDep === nextDep\n\n if (!dependencyMatches) {\n const prevInstance = prevLead.instance as HTMLElement | undefined\n const isStale = prevInstance && prevInstance.isConnected === false && !prevLead.snapshot\n\n if (!isStale) {\n node.resumeFrom = prevLead\n\n if (preserveFollowOpacity) {\n node.resumeFrom.preserveOpacity = true\n }\n\n if (prevLead.snapshot) {\n node.snapshot = prevLead.snapshot\n node.snapshot.latestValues =\n prevLead.animationValues || prevLead.latestValues\n }\n\n if (node.root && node.root.isUpdating) {\n node.isLayoutDirty = true\n }\n }\n }\n\n const { crossfade } = node.options\n if (crossfade === false) {\n prevLead.hide()\n }\n }\n }\n\n exitAnimationComplete() {\n this.members.forEach((node) => {\n const { options, resumingFrom } = node\n\n options.onExitComplete && options.onExitComplete()\n\n if (resumingFrom) {\n resumingFrom.options.onExitComplete &&\n resumingFrom.options.onExitComplete()\n }\n })\n }\n\n scheduleRender() {\n this.members.forEach((node) => {\n node.instance && node.scheduleRender(false)\n })\n }\n\n /**\n * Clear any leads that have been removed this render to prevent them from being\n * used in future animations and to prevent memory leaks\n */\n removeLeadSnapshot() {\n if (this.lead && this.lead.snapshot) {\n this.lead.snapshot = undefined\n }\n }\n}\n"],"names":[],"mappings":";;MAGa,SAAS,CAAA;AAAtB,IAAA,WAAA,GAAA;QAGI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,OAAO,CAAC,CAAC,IAAI,KAAI;AAC1B,YAAA,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,IAAI,CAAA;AAEtC,YAAA,OAAO,CAAC,cAAc,IAAI,OAAO,CAAC,cAAc,EAAE,CAAA;YAElD,IAAI,YAAY,EAAE;gBACd,YAAY,CAAC,OAAO,CAAC,cAAc;AAC/B,oBAAA,YAAY,CAAC,OAAO,CAAC,cAAc,EAAE,CAAA;aAC5C;AACL,SAAC,CAAC,CAAA;KACL;IAED,cAAc,GAAA;QACV,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;YAC1B,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;AAC/C,SAAC,CAAC,CAAA;KACL;AAED;;;AAGG;IACH,kBAAkB,GAAA;QACd,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;AACjC,YAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAA;SACjC;KACJ;AACJ;;;;"}
|
|
@@ -124,6 +124,22 @@ function createAnimationState(visualElement) {
|
|
|
124
124
|
typeof prop === "boolean") {
|
|
125
125
|
continue;
|
|
126
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* If exit is already active and wasn't just activated, skip
|
|
129
|
+
* re-processing to prevent interrupting running exit animations.
|
|
130
|
+
* Re-resolving exit with a changed custom value can start new
|
|
131
|
+
* value animations that stop the originals, leaving the exit
|
|
132
|
+
* animation promise unresolved and the component stuck in the DOM.
|
|
133
|
+
*/
|
|
134
|
+
if (type === "exit" && typeState.isActive && activeDelta !== true) {
|
|
135
|
+
if (typeState.prevResolvedValues) {
|
|
136
|
+
encounteredKeys = {
|
|
137
|
+
...encounteredKeys,
|
|
138
|
+
...typeState.prevResolvedValues,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
127
143
|
/**
|
|
128
144
|
* As we go look through the values defined on this type, if we detect
|
|
129
145
|
* a changed value or a value that was removed in a higher priority, we set
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animation-state.mjs","sources":["../../../../src/render/utils/animation-state.ts"],"sourcesContent":["import type {\n AnimationDefinition,\n TargetAndTransition,\n VariantLabels,\n} from \"../../node/types\"\nimport type { AnimationType } from \"../types\"\nimport type { VisualElementAnimationOptions } from \"../../animation/interfaces/types\"\nimport { animateVisualElement } from \"../../animation/interfaces/visual-element\"\nimport { calcChildStagger } from \"../../animation/utils/calc-child-stagger\"\nimport { getVariantContext } from \"./get-variant-context\"\nimport { isAnimationControls } from \"./is-animation-controls\"\nimport { isKeyframesTarget } from \"./is-keyframes-target\"\nimport { isVariantLabel } from \"./is-variant-label\"\nimport { resolveVariant } from \"./resolve-dynamic-variants\"\nimport { shallowCompare } from \"./shallow-compare\"\nimport { variantPriorityOrder } from \"./variant-props\"\n\nexport type { VisualElementAnimationOptions }\n\nexport interface AnimationState {\n animateChanges: (type?: AnimationType) => Promise<any>\n setActive: (\n type: AnimationType,\n isActive: boolean,\n options?: VisualElementAnimationOptions\n ) => Promise<any>\n setAnimateFunction: (fn: any) => void\n getState: () => { [key: string]: AnimationTypeState }\n reset: () => void\n}\n\ninterface DefinitionAndOptions {\n animation: AnimationDefinition\n options?: VisualElementAnimationOptions\n}\n\nexport type AnimationList = string[] | TargetAndTransition[]\n\nconst reversePriorityOrder = [...variantPriorityOrder].reverse()\nconst numAnimationTypes = variantPriorityOrder.length\n\n/**\n * Type for the animate function that can be injected.\n * This allows the animation implementation to be provided by the framework layer.\n */\nexport type AnimateFunction = (animations: DefinitionAndOptions[]) => Promise<any>\n\nfunction createAnimateFunction(visualElement: any): AnimateFunction {\n return (animations: DefinitionAndOptions[]) => {\n return Promise.all(\n animations.map(({ animation, options }) =>\n animateVisualElement(visualElement, animation, options)\n )\n )\n }\n}\n\nexport function createAnimationState(visualElement: any): AnimationState {\n let animate = createAnimateFunction(visualElement)\n let state = createState()\n let isInitialRender = true\n\n /**\n * This function will be used to reduce the animation definitions for\n * each active animation type into an object of resolved values for it.\n */\n const buildResolvedTypeValues =\n (type: AnimationType) =>\n (\n acc: { [key: string]: any },\n definition: string | TargetAndTransition | undefined\n ) => {\n const resolved = resolveVariant(\n visualElement,\n definition,\n type === \"exit\"\n ? visualElement.presenceContext?.custom\n : undefined\n )\n\n if (resolved) {\n const { transition, transitionEnd, ...target } = resolved\n acc = { ...acc, ...target, ...transitionEnd }\n }\n\n return acc\n }\n\n /**\n * This just allows us to inject mocked animation functions\n * @internal\n */\n function setAnimateFunction(\n makeAnimator: (visualElement: any) => AnimateFunction\n ) {\n animate = makeAnimator(visualElement)\n }\n\n /**\n * When we receive new props, we need to:\n * 1. Create a list of protected keys for each type. This is a directory of\n * value keys that are currently being \"handled\" by types of a higher priority\n * so that whenever an animation is played of a given type, these values are\n * protected from being animated.\n * 2. Determine if an animation type needs animating.\n * 3. Determine if any values have been removed from a type and figure out\n * what to animate those to.\n */\n function animateChanges(changedActiveType?: AnimationType) {\n const { props } = visualElement\n const context = getVariantContext(visualElement.parent) || {}\n\n /**\n * A list of animations that we'll build into as we iterate through the animation\n * types. This will get executed at the end of the function.\n */\n const animations: DefinitionAndOptions[] = []\n\n /**\n * Keep track of which values have been removed. Then, as we hit lower priority\n * animation types, we can check if they contain removed values and animate to that.\n */\n const removedKeys = new Set<string>()\n\n /**\n * A dictionary of all encountered keys. This is an object to let us build into and\n * copy it without iteration. Each time we hit an animation type we set its protected\n * keys - the keys its not allowed to animate - to the latest version of this object.\n */\n let encounteredKeys: { [key: string]: any } = {}\n\n /**\n * If a variant has been removed at a given index, and this component is controlling\n * variant animations, we want to ensure lower-priority variants are forced to animate.\n */\n let removedVariantIndex = Infinity\n\n /**\n * Iterate through all animation types in reverse priority order. For each, we want to\n * detect which values it's handling and whether or not they've changed (and therefore\n * need to be animated). If any values have been removed, we want to detect those in\n * lower priority props and flag for animation.\n */\n for (let i = 0; i < numAnimationTypes; i++) {\n const type = reversePriorityOrder[i]\n const typeState = state[type]\n const prop =\n props[type] !== undefined\n ? props[type]\n : context[type as keyof typeof context]\n const propIsVariant = isVariantLabel(prop)\n\n /**\n * If this type has *just* changed isActive status, set activeDelta\n * to that status. Otherwise set to null.\n */\n const activeDelta =\n type === changedActiveType ? typeState.isActive : null\n\n if (activeDelta === false) removedVariantIndex = i\n\n /**\n * If this prop is an inherited variant, rather than been set directly on the\n * component itself, we want to make sure we allow the parent to trigger animations.\n *\n * TODO: Can probably change this to a !isControllingVariants check\n */\n let isInherited =\n prop === context[type as keyof typeof context] &&\n prop !== props[type] &&\n propIsVariant\n\n if (\n isInherited &&\n isInitialRender &&\n visualElement.manuallyAnimateOnMount\n ) {\n isInherited = false\n }\n\n /**\n * Set all encountered keys so far as the protected keys for this type. This will\n * be any key that has been animated or otherwise handled by active, higher-priortiy types.\n */\n typeState.protectedKeys = { ...encounteredKeys }\n\n // Check if we can skip analysing this prop early\n if (\n // If it isn't active and hasn't *just* been set as inactive\n (!typeState.isActive && activeDelta === null) ||\n // If we didn't and don't have any defined prop for this animation type\n (!prop && !typeState.prevProp) ||\n // Or if the prop doesn't define an animation\n isAnimationControls(prop) ||\n typeof prop === \"boolean\"\n ) {\n continue\n }\n\n /**\n * As we go look through the values defined on this type, if we detect\n * a changed value or a value that was removed in a higher priority, we set\n * this to true and add this prop to the animation list.\n */\n const variantDidChange = checkVariantsDidChange(\n typeState.prevProp,\n prop\n )\n\n let shouldAnimateType =\n variantDidChange ||\n // If we're making this variant active, we want to always make it active\n (type === changedActiveType &&\n typeState.isActive &&\n !isInherited &&\n propIsVariant) ||\n // If we removed a higher-priority variant (i is in reverse order)\n (i > removedVariantIndex && propIsVariant)\n\n let handledRemovedValues = false\n\n /**\n * As animations can be set as variant lists, variants or target objects, we\n * coerce everything to an array if it isn't one already\n */\n const definitionList = Array.isArray(prop) ? prop : [prop]\n\n /**\n * Build an object of all the resolved values. We'll use this in the subsequent\n * animateChanges calls to determine whether a value has changed.\n */\n let resolvedValues = definitionList.reduce(\n buildResolvedTypeValues(type),\n {}\n )\n\n if (activeDelta === false) resolvedValues = {}\n\n /**\n * Now we need to loop through all the keys in the prev prop and this prop,\n * and decide:\n * 1. If the value has changed, and needs animating\n * 2. If it has been removed, and needs adding to the removedKeys set\n * 3. If it has been removed in a higher priority type and needs animating\n * 4. If it hasn't been removed in a higher priority but hasn't changed, and\n * needs adding to the type's protectedKeys list.\n */\n const { prevResolvedValues = {} } = typeState\n\n const allKeys = {\n ...prevResolvedValues,\n ...resolvedValues,\n }\n const markToAnimate = (key: string) => {\n shouldAnimateType = true\n if (removedKeys.has(key)) {\n handledRemovedValues = true\n removedKeys.delete(key)\n }\n typeState.needsAnimating[key] = true\n\n const motionValue = visualElement.getValue(key)\n if (motionValue) motionValue.liveStyle = false\n }\n\n for (const key in allKeys) {\n const next = resolvedValues[key]\n const prev = prevResolvedValues[key]\n\n // If we've already handled this we can just skip ahead\n if (encounteredKeys.hasOwnProperty(key)) continue\n\n /**\n * If the value has changed, we probably want to animate it.\n */\n let valueHasChanged = false\n if (isKeyframesTarget(next) && isKeyframesTarget(prev)) {\n valueHasChanged = !shallowCompare(next, prev)\n } else {\n valueHasChanged = next !== prev\n }\n\n if (valueHasChanged) {\n if (next !== undefined && next !== null) {\n // If next is defined and doesn't equal prev, it needs animating\n markToAnimate(key)\n } else {\n // If it's undefined, it's been removed.\n removedKeys.add(key)\n }\n } else if (next !== undefined && removedKeys.has(key)) {\n /**\n * If next hasn't changed and it isn't undefined, we want to check if it's\n * been removed by a higher priority\n */\n markToAnimate(key)\n } else {\n /**\n * If it hasn't changed, we add it to the list of protected values\n * to ensure it doesn't get animated.\n */\n typeState.protectedKeys[key] = true\n }\n }\n\n /**\n * Update the typeState so next time animateChanges is called we can compare the\n * latest prop and resolvedValues to these.\n */\n typeState.prevProp = prop\n typeState.prevResolvedValues = resolvedValues\n\n if (typeState.isActive) {\n encounteredKeys = { ...encounteredKeys, ...resolvedValues }\n }\n\n if (isInitialRender && visualElement.blockInitialAnimation) {\n shouldAnimateType = false\n }\n\n /**\n * If this is an inherited prop we want to skip this animation\n * unless the inherited variants haven't changed on this render.\n */\n const willAnimateViaParent = isInherited && variantDidChange\n const needsAnimating = !willAnimateViaParent || handledRemovedValues\n if (shouldAnimateType && needsAnimating) {\n animations.push(\n ...definitionList.map((animation) => {\n const options: VisualElementAnimationOptions = { type }\n\n /**\n * If we're performing the initial animation, but we're not\n * rendering at the same time as the variant-controlling parent,\n * we want to use the parent's transition to calculate the stagger.\n */\n if (\n typeof animation === \"string\" &&\n isInitialRender &&\n !willAnimateViaParent &&\n visualElement.manuallyAnimateOnMount &&\n visualElement.parent\n ) {\n const { parent } = visualElement\n const parentVariant = resolveVariant(\n parent,\n animation\n )\n\n if (parent.enteringChildren && parentVariant) {\n const { delayChildren } =\n parentVariant.transition || {}\n options.delay = calcChildStagger(\n parent.enteringChildren,\n visualElement,\n delayChildren\n )\n }\n }\n\n return {\n animation: animation as AnimationDefinition,\n options,\n }\n })\n )\n }\n }\n\n /**\n * If there are some removed value that haven't been dealt with,\n * we need to create a new animation that falls back either to the value\n * defined in the style prop, or the last read value.\n */\n if (removedKeys.size) {\n const fallbackAnimation: TargetAndTransition = {}\n\n /**\n * If the initial prop contains a transition we can use that, otherwise\n * allow the animation function to use the visual element's default.\n */\n if (typeof props.initial !== \"boolean\") {\n const initialTransition = resolveVariant(\n visualElement,\n Array.isArray(props.initial)\n ? props.initial[0]\n : props.initial\n )\n\n if (initialTransition && initialTransition.transition) {\n fallbackAnimation.transition = initialTransition.transition\n }\n }\n\n removedKeys.forEach((key) => {\n const fallbackTarget = visualElement.getBaseTarget(key)\n\n const motionValue = visualElement.getValue(key)\n if (motionValue) motionValue.liveStyle = true\n\n // @ts-expect-error - @mattgperry to figure if we should do something here\n fallbackAnimation[key] = fallbackTarget ?? null\n })\n\n animations.push({ animation: fallbackAnimation })\n }\n\n let shouldAnimate = Boolean(animations.length)\n\n if (\n isInitialRender &&\n (props.initial === false || props.initial === props.animate) &&\n !visualElement.manuallyAnimateOnMount\n ) {\n shouldAnimate = false\n }\n\n isInitialRender = false\n return shouldAnimate ? animate(animations) : Promise.resolve()\n }\n\n /**\n * Change whether a certain animation type is active.\n */\n function setActive(type: AnimationType, isActive: boolean) {\n // If the active state hasn't changed, we can safely do nothing here\n if (state[type].isActive === isActive) return Promise.resolve()\n\n // Propagate active change to children\n visualElement.variantChildren?.forEach((child: any) =>\n child.animationState?.setActive(type, isActive)\n )\n\n state[type].isActive = isActive\n\n const animations = animateChanges(type)\n\n for (const key in state) {\n state[key as keyof typeof state].protectedKeys = {}\n }\n\n return animations\n }\n\n return {\n animateChanges,\n setActive,\n setAnimateFunction,\n getState: () => state,\n reset: () => {\n state = createState()\n /**\n * Temporarily disabling resetting this flag as it prevents components\n * with initial={false} from animating after being remounted, for instance\n * as the child of an Activity component.\n */\n // isInitialRender = true\n },\n }\n}\n\nexport function checkVariantsDidChange(prev: any, next: any) {\n if (typeof next === \"string\") {\n return next !== prev\n } else if (Array.isArray(next)) {\n return !shallowCompare(next, prev)\n }\n\n return false\n}\n\nexport interface AnimationTypeState {\n isActive: boolean\n protectedKeys: { [key: string]: true }\n needsAnimating: { [key: string]: boolean }\n prevResolvedValues: { [key: string]: any }\n prevProp?: VariantLabels | TargetAndTransition\n}\n\nfunction createTypeState(isActive = false): AnimationTypeState {\n return {\n isActive,\n protectedKeys: {},\n needsAnimating: {},\n prevResolvedValues: {},\n }\n}\n\nfunction createState() {\n return {\n animate: createTypeState(true),\n whileInView: createTypeState(),\n whileHover: createTypeState(),\n whileTap: createTypeState(),\n whileDrag: createTypeState(),\n whileFocus: createTypeState(),\n exit: createTypeState(),\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AAsCA,MAAM,oBAAoB,GAAG,CAAC,GAAG,oBAAoB,CAAC,CAAC,OAAO,EAAE,CAAA;AAChE,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,MAA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AED,IAAA,OAAO,KAAK,CAAA;AAChB,CAAC;AAUD,SAAS,eAAe,CAAC,QAAQ,GAAG,KAAK,EAAA;IACrC,OAAO;QACH,QAAQ;AACR,QAAA,aAAa,EAAE,EAAE;AACjB,QAAA,cAAc,EAAE,EAAE;AAClB,QAAA,kBAAkB,EAAE,EAAE;KACzB,CAAA;AACL,CAAC;AAED,SAAS,WAAW,GAAA;IAChB,OAAO;AACH,QAAA,OAAO,EAAE,eAAe,CAAC,IAAI,CAAC;QAC9B,WAAW,EAAE,eAAe,EAAE;QAC9B,UAAU,EAAE,eAAe,EAAE;QAC7B,QAAQ,EAAE,eAAe,EAAE;QAC3B,SAAS,EAAE,eAAe,EAAE;QAC5B,UAAU,EAAE,eAAe,EAAE;QAC7B,IAAI,EAAE,eAAe,EAAE;KAC1B,CAAA;AACL;;;;"}
|
|
1
|
+
{"version":3,"file":"animation-state.mjs","sources":["../../../../src/render/utils/animation-state.ts"],"sourcesContent":["import type {\n AnimationDefinition,\n TargetAndTransition,\n VariantLabels,\n} from \"../../node/types\"\nimport type { AnimationType } from \"../types\"\nimport type { VisualElementAnimationOptions } from \"../../animation/interfaces/types\"\nimport { animateVisualElement } from \"../../animation/interfaces/visual-element\"\nimport { calcChildStagger } from \"../../animation/utils/calc-child-stagger\"\nimport { getVariantContext } from \"./get-variant-context\"\nimport { isAnimationControls } from \"./is-animation-controls\"\nimport { isKeyframesTarget } from \"./is-keyframes-target\"\nimport { isVariantLabel } from \"./is-variant-label\"\nimport { resolveVariant } from \"./resolve-dynamic-variants\"\nimport { shallowCompare } from \"./shallow-compare\"\nimport { variantPriorityOrder } from \"./variant-props\"\n\nexport type { VisualElementAnimationOptions }\n\nexport interface AnimationState {\n animateChanges: (type?: AnimationType) => Promise<any>\n setActive: (\n type: AnimationType,\n isActive: boolean,\n options?: VisualElementAnimationOptions\n ) => Promise<any>\n setAnimateFunction: (fn: any) => void\n getState: () => { [key: string]: AnimationTypeState }\n reset: () => void\n}\n\ninterface DefinitionAndOptions {\n animation: AnimationDefinition\n options?: VisualElementAnimationOptions\n}\n\nexport type AnimationList = string[] | TargetAndTransition[]\n\nconst reversePriorityOrder = [...variantPriorityOrder].reverse()\nconst numAnimationTypes = variantPriorityOrder.length\n\n/**\n * Type for the animate function that can be injected.\n * This allows the animation implementation to be provided by the framework layer.\n */\nexport type AnimateFunction = (animations: DefinitionAndOptions[]) => Promise<any>\n\nfunction createAnimateFunction(visualElement: any): AnimateFunction {\n return (animations: DefinitionAndOptions[]) => {\n return Promise.all(\n animations.map(({ animation, options }) =>\n animateVisualElement(visualElement, animation, options)\n )\n )\n }\n}\n\nexport function createAnimationState(visualElement: any): AnimationState {\n let animate = createAnimateFunction(visualElement)\n let state = createState()\n let isInitialRender = true\n\n /**\n * This function will be used to reduce the animation definitions for\n * each active animation type into an object of resolved values for it.\n */\n const buildResolvedTypeValues =\n (type: AnimationType) =>\n (\n acc: { [key: string]: any },\n definition: string | TargetAndTransition | undefined\n ) => {\n const resolved = resolveVariant(\n visualElement,\n definition,\n type === \"exit\"\n ? visualElement.presenceContext?.custom\n : undefined\n )\n\n if (resolved) {\n const { transition, transitionEnd, ...target } = resolved\n acc = { ...acc, ...target, ...transitionEnd }\n }\n\n return acc\n }\n\n /**\n * This just allows us to inject mocked animation functions\n * @internal\n */\n function setAnimateFunction(\n makeAnimator: (visualElement: any) => AnimateFunction\n ) {\n animate = makeAnimator(visualElement)\n }\n\n /**\n * When we receive new props, we need to:\n * 1. Create a list of protected keys for each type. This is a directory of\n * value keys that are currently being \"handled\" by types of a higher priority\n * so that whenever an animation is played of a given type, these values are\n * protected from being animated.\n * 2. Determine if an animation type needs animating.\n * 3. Determine if any values have been removed from a type and figure out\n * what to animate those to.\n */\n function animateChanges(changedActiveType?: AnimationType) {\n const { props } = visualElement\n const context = getVariantContext(visualElement.parent) || {}\n\n /**\n * A list of animations that we'll build into as we iterate through the animation\n * types. This will get executed at the end of the function.\n */\n const animations: DefinitionAndOptions[] = []\n\n /**\n * Keep track of which values have been removed. Then, as we hit lower priority\n * animation types, we can check if they contain removed values and animate to that.\n */\n const removedKeys = new Set<string>()\n\n /**\n * A dictionary of all encountered keys. This is an object to let us build into and\n * copy it without iteration. Each time we hit an animation type we set its protected\n * keys - the keys its not allowed to animate - to the latest version of this object.\n */\n let encounteredKeys: { [key: string]: any } = {}\n\n /**\n * If a variant has been removed at a given index, and this component is controlling\n * variant animations, we want to ensure lower-priority variants are forced to animate.\n */\n let removedVariantIndex = Infinity\n\n /**\n * Iterate through all animation types in reverse priority order. For each, we want to\n * detect which values it's handling and whether or not they've changed (and therefore\n * need to be animated). If any values have been removed, we want to detect those in\n * lower priority props and flag for animation.\n */\n for (let i = 0; i < numAnimationTypes; i++) {\n const type = reversePriorityOrder[i]\n const typeState = state[type]\n const prop =\n props[type] !== undefined\n ? props[type]\n : context[type as keyof typeof context]\n const propIsVariant = isVariantLabel(prop)\n\n /**\n * If this type has *just* changed isActive status, set activeDelta\n * to that status. Otherwise set to null.\n */\n const activeDelta =\n type === changedActiveType ? typeState.isActive : null\n\n if (activeDelta === false) removedVariantIndex = i\n\n /**\n * If this prop is an inherited variant, rather than been set directly on the\n * component itself, we want to make sure we allow the parent to trigger animations.\n *\n * TODO: Can probably change this to a !isControllingVariants check\n */\n let isInherited =\n prop === context[type as keyof typeof context] &&\n prop !== props[type] &&\n propIsVariant\n\n if (\n isInherited &&\n isInitialRender &&\n visualElement.manuallyAnimateOnMount\n ) {\n isInherited = false\n }\n\n /**\n * Set all encountered keys so far as the protected keys for this type. This will\n * be any key that has been animated or otherwise handled by active, higher-priortiy types.\n */\n typeState.protectedKeys = { ...encounteredKeys }\n\n // Check if we can skip analysing this prop early\n if (\n // If it isn't active and hasn't *just* been set as inactive\n (!typeState.isActive && activeDelta === null) ||\n // If we didn't and don't have any defined prop for this animation type\n (!prop && !typeState.prevProp) ||\n // Or if the prop doesn't define an animation\n isAnimationControls(prop) ||\n typeof prop === \"boolean\"\n ) {\n continue\n }\n\n /**\n * If exit is already active and wasn't just activated, skip\n * re-processing to prevent interrupting running exit animations.\n * Re-resolving exit with a changed custom value can start new\n * value animations that stop the originals, leaving the exit\n * animation promise unresolved and the component stuck in the DOM.\n */\n if (type === \"exit\" && typeState.isActive && activeDelta !== true) {\n if (typeState.prevResolvedValues) {\n encounteredKeys = {\n ...encounteredKeys,\n ...typeState.prevResolvedValues,\n }\n }\n continue\n }\n\n /**\n * As we go look through the values defined on this type, if we detect\n * a changed value or a value that was removed in a higher priority, we set\n * this to true and add this prop to the animation list.\n */\n const variantDidChange = checkVariantsDidChange(\n typeState.prevProp,\n prop\n )\n\n let shouldAnimateType =\n variantDidChange ||\n // If we're making this variant active, we want to always make it active\n (type === changedActiveType &&\n typeState.isActive &&\n !isInherited &&\n propIsVariant) ||\n // If we removed a higher-priority variant (i is in reverse order)\n (i > removedVariantIndex && propIsVariant)\n\n let handledRemovedValues = false\n\n /**\n * As animations can be set as variant lists, variants or target objects, we\n * coerce everything to an array if it isn't one already\n */\n const definitionList = Array.isArray(prop) ? prop : [prop]\n\n /**\n * Build an object of all the resolved values. We'll use this in the subsequent\n * animateChanges calls to determine whether a value has changed.\n */\n let resolvedValues = definitionList.reduce(\n buildResolvedTypeValues(type),\n {}\n )\n\n if (activeDelta === false) resolvedValues = {}\n\n /**\n * Now we need to loop through all the keys in the prev prop and this prop,\n * and decide:\n * 1. If the value has changed, and needs animating\n * 2. If it has been removed, and needs adding to the removedKeys set\n * 3. If it has been removed in a higher priority type and needs animating\n * 4. If it hasn't been removed in a higher priority but hasn't changed, and\n * needs adding to the type's protectedKeys list.\n */\n const { prevResolvedValues = {} } = typeState\n\n const allKeys = {\n ...prevResolvedValues,\n ...resolvedValues,\n }\n const markToAnimate = (key: string) => {\n shouldAnimateType = true\n if (removedKeys.has(key)) {\n handledRemovedValues = true\n removedKeys.delete(key)\n }\n typeState.needsAnimating[key] = true\n\n const motionValue = visualElement.getValue(key)\n if (motionValue) motionValue.liveStyle = false\n }\n\n for (const key in allKeys) {\n const next = resolvedValues[key]\n const prev = prevResolvedValues[key]\n\n // If we've already handled this we can just skip ahead\n if (encounteredKeys.hasOwnProperty(key)) continue\n\n /**\n * If the value has changed, we probably want to animate it.\n */\n let valueHasChanged = false\n if (isKeyframesTarget(next) && isKeyframesTarget(prev)) {\n valueHasChanged = !shallowCompare(next, prev)\n } else {\n valueHasChanged = next !== prev\n }\n\n if (valueHasChanged) {\n if (next !== undefined && next !== null) {\n // If next is defined and doesn't equal prev, it needs animating\n markToAnimate(key)\n } else {\n // If it's undefined, it's been removed.\n removedKeys.add(key)\n }\n } else if (next !== undefined && removedKeys.has(key)) {\n /**\n * If next hasn't changed and it isn't undefined, we want to check if it's\n * been removed by a higher priority\n */\n markToAnimate(key)\n } else {\n /**\n * If it hasn't changed, we add it to the list of protected values\n * to ensure it doesn't get animated.\n */\n typeState.protectedKeys[key] = true\n }\n }\n\n /**\n * Update the typeState so next time animateChanges is called we can compare the\n * latest prop and resolvedValues to these.\n */\n typeState.prevProp = prop\n typeState.prevResolvedValues = resolvedValues\n\n if (typeState.isActive) {\n encounteredKeys = { ...encounteredKeys, ...resolvedValues }\n }\n\n if (isInitialRender && visualElement.blockInitialAnimation) {\n shouldAnimateType = false\n }\n\n /**\n * If this is an inherited prop we want to skip this animation\n * unless the inherited variants haven't changed on this render.\n */\n const willAnimateViaParent = isInherited && variantDidChange\n const needsAnimating = !willAnimateViaParent || handledRemovedValues\n if (shouldAnimateType && needsAnimating) {\n animations.push(\n ...definitionList.map((animation) => {\n const options: VisualElementAnimationOptions = { type }\n\n /**\n * If we're performing the initial animation, but we're not\n * rendering at the same time as the variant-controlling parent,\n * we want to use the parent's transition to calculate the stagger.\n */\n if (\n typeof animation === \"string\" &&\n isInitialRender &&\n !willAnimateViaParent &&\n visualElement.manuallyAnimateOnMount &&\n visualElement.parent\n ) {\n const { parent } = visualElement\n const parentVariant = resolveVariant(\n parent,\n animation\n )\n\n if (parent.enteringChildren && parentVariant) {\n const { delayChildren } =\n parentVariant.transition || {}\n options.delay = calcChildStagger(\n parent.enteringChildren,\n visualElement,\n delayChildren\n )\n }\n }\n\n return {\n animation: animation as AnimationDefinition,\n options,\n }\n })\n )\n }\n }\n\n /**\n * If there are some removed value that haven't been dealt with,\n * we need to create a new animation that falls back either to the value\n * defined in the style prop, or the last read value.\n */\n if (removedKeys.size) {\n const fallbackAnimation: TargetAndTransition = {}\n\n /**\n * If the initial prop contains a transition we can use that, otherwise\n * allow the animation function to use the visual element's default.\n */\n if (typeof props.initial !== \"boolean\") {\n const initialTransition = resolveVariant(\n visualElement,\n Array.isArray(props.initial)\n ? props.initial[0]\n : props.initial\n )\n\n if (initialTransition && initialTransition.transition) {\n fallbackAnimation.transition = initialTransition.transition\n }\n }\n\n removedKeys.forEach((key) => {\n const fallbackTarget = visualElement.getBaseTarget(key)\n\n const motionValue = visualElement.getValue(key)\n if (motionValue) motionValue.liveStyle = true\n\n // @ts-expect-error - @mattgperry to figure if we should do something here\n fallbackAnimation[key] = fallbackTarget ?? null\n })\n\n animations.push({ animation: fallbackAnimation })\n }\n\n let shouldAnimate = Boolean(animations.length)\n\n if (\n isInitialRender &&\n (props.initial === false || props.initial === props.animate) &&\n !visualElement.manuallyAnimateOnMount\n ) {\n shouldAnimate = false\n }\n\n isInitialRender = false\n return shouldAnimate ? animate(animations) : Promise.resolve()\n }\n\n /**\n * Change whether a certain animation type is active.\n */\n function setActive(type: AnimationType, isActive: boolean) {\n // If the active state hasn't changed, we can safely do nothing here\n if (state[type].isActive === isActive) return Promise.resolve()\n\n // Propagate active change to children\n visualElement.variantChildren?.forEach((child: any) =>\n child.animationState?.setActive(type, isActive)\n )\n\n state[type].isActive = isActive\n\n const animations = animateChanges(type)\n\n for (const key in state) {\n state[key as keyof typeof state].protectedKeys = {}\n }\n\n return animations\n }\n\n return {\n animateChanges,\n setActive,\n setAnimateFunction,\n getState: () => state,\n reset: () => {\n state = createState()\n /**\n * Temporarily disabling resetting this flag as it prevents components\n * with initial={false} from animating after being remounted, for instance\n * as the child of an Activity component.\n */\n // isInitialRender = true\n },\n }\n}\n\nexport function checkVariantsDidChange(prev: any, next: any) {\n if (typeof next === \"string\") {\n return next !== prev\n } else if (Array.isArray(next)) {\n return !shallowCompare(next, prev)\n }\n\n return false\n}\n\nexport interface AnimationTypeState {\n isActive: boolean\n protectedKeys: { [key: string]: true }\n needsAnimating: { [key: string]: boolean }\n prevResolvedValues: { [key: string]: any }\n prevProp?: VariantLabels | TargetAndTransition\n}\n\nfunction createTypeState(isActive = false): AnimationTypeState {\n return {\n isActive,\n protectedKeys: {},\n needsAnimating: {},\n prevResolvedValues: {},\n }\n}\n\nfunction createState() {\n return {\n animate: createTypeState(true),\n whileInView: createTypeState(),\n whileHover: createTypeState(),\n whileTap: createTypeState(),\n whileDrag: createTypeState(),\n whileFocus: createTypeState(),\n exit: createTypeState(),\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AAsCA,MAAM,oBAAoB,GAAG,CAAC,GAAG,oBAAoB,CAAC,CAAC,OAAO,EAAE,CAAA;AAChE,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,MAAM,CAAA;AAQrD,SAAS,qBAAqB,CAAC,aAAkB,EAAA;IAC7C,OAAO,CAAC,UAAkC,KAAI;QAC1C,OAAO,OAAO,CAAC,GAAG,CACd,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,KAClC,oBAAoB,CAAC,aAAa,EAAE,SAAS,EAAE,OAAO,CAAC,CAC1D,CACJ,CAAA;AACL,KAAC,CAAA;AACL,CAAC;AAEK,SAAU,oBAAoB,CAAC,aAAkB,EAAA;AACnD,IAAA,IAAI,OAAO,GAAG,qBAAqB,CAAC,aAAa,CAAC,CAAA;AAClD,IAAA,IAAI,KAAK,GAAG,WAAW,EAAE,CAAA;IACzB,IAAI,eAAe,GAAG,IAAI,CAAA;AAE1B;;;AAGG;AACH,IAAA,MAAM,uBAAuB,GACzB,CAAC,IAAmB,KACpB,CACI,GAA2B,EA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,OAAO,EAAE,eAAe,CAAC,IAAI,CAAC;QAC9B,WAAW,EAAE,eAAe,EAAE;QAC9B,UAAU,EAAE,eAAe,EAAE;QAC7B,QAAQ,EAAE,eAAe,EAAE;QAC3B,SAAS,EAAE,eAAe,EAAE;QAC5B,UAAU,EAAE,eAAe,EAAE;QAC7B,IAAI,EAAE,eAAe,EAAE;KAC1B,CAAA;AACL;;;;"}
|
package/dist/motion-dom.dev.js
CHANGED
|
@@ -6827,6 +6827,22 @@
|
|
|
6827
6827
|
typeof prop === "boolean") {
|
|
6828
6828
|
continue;
|
|
6829
6829
|
}
|
|
6830
|
+
/**
|
|
6831
|
+
* If exit is already active and wasn't just activated, skip
|
|
6832
|
+
* re-processing to prevent interrupting running exit animations.
|
|
6833
|
+
* Re-resolving exit with a changed custom value can start new
|
|
6834
|
+
* value animations that stop the originals, leaving the exit
|
|
6835
|
+
* animation promise unresolved and the component stuck in the DOM.
|
|
6836
|
+
*/
|
|
6837
|
+
if (type === "exit" && typeState.isActive && activeDelta !== true) {
|
|
6838
|
+
if (typeState.prevResolvedValues) {
|
|
6839
|
+
encounteredKeys = {
|
|
6840
|
+
...encounteredKeys,
|
|
6841
|
+
...typeState.prevResolvedValues,
|
|
6842
|
+
};
|
|
6843
|
+
}
|
|
6844
|
+
continue;
|
|
6845
|
+
}
|
|
6830
6846
|
/**
|
|
6831
6847
|
* As we go look through the values defined on this type, if we detect
|
|
6832
6848
|
* a changed value or a value that was removed in a higher priority, we set
|
|
@@ -7398,6 +7414,15 @@
|
|
|
7398
7414
|
}
|
|
7399
7415
|
add(node) {
|
|
7400
7416
|
motionUtils.addUniqueItem(this.members, node);
|
|
7417
|
+
for (let i = this.members.length - 1; i >= 0; i--) {
|
|
7418
|
+
const m = this.members[i];
|
|
7419
|
+
if (m === node || m === this.lead || m === this.prevLead)
|
|
7420
|
+
continue;
|
|
7421
|
+
const inst = m.instance;
|
|
7422
|
+
if (inst && inst.isConnected === false && m.isPresent !== false && !m.snapshot) {
|
|
7423
|
+
motionUtils.removeItem(this.members, m);
|
|
7424
|
+
}
|
|
7425
|
+
}
|
|
7401
7426
|
node.scheduleRender();
|
|
7402
7427
|
}
|
|
7403
7428
|
remove(node) {
|
|
@@ -7422,7 +7447,8 @@
|
|
|
7422
7447
|
let prevLead;
|
|
7423
7448
|
for (let i = indexOfNode; i >= 0; i--) {
|
|
7424
7449
|
const member = this.members[i];
|
|
7425
|
-
|
|
7450
|
+
const inst = member.instance;
|
|
7451
|
+
if (member.isPresent !== false && (!inst || inst.isConnected !== false)) {
|
|
7426
7452
|
prevLead = member;
|
|
7427
7453
|
break;
|
|
7428
7454
|
}
|
|
@@ -7457,17 +7483,21 @@
|
|
|
7457
7483
|
nextDep !== undefined &&
|
|
7458
7484
|
prevDep === nextDep;
|
|
7459
7485
|
if (!dependencyMatches) {
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7486
|
+
const prevInstance = prevLead.instance;
|
|
7487
|
+
const isStale = prevInstance && prevInstance.isConnected === false && !prevLead.snapshot;
|
|
7488
|
+
if (!isStale) {
|
|
7489
|
+
node.resumeFrom = prevLead;
|
|
7490
|
+
if (preserveFollowOpacity) {
|
|
7491
|
+
node.resumeFrom.preserveOpacity = true;
|
|
7492
|
+
}
|
|
7493
|
+
if (prevLead.snapshot) {
|
|
7494
|
+
node.snapshot = prevLead.snapshot;
|
|
7495
|
+
node.snapshot.latestValues =
|
|
7496
|
+
prevLead.animationValues || prevLead.latestValues;
|
|
7497
|
+
}
|
|
7498
|
+
if (node.root && node.root.isUpdating) {
|
|
7499
|
+
node.isLayoutDirty = true;
|
|
7500
|
+
}
|
|
7471
7501
|
}
|
|
7472
7502
|
}
|
|
7473
7503
|
const { crossfade } = node.options;
|