motion-dom 14.0.0 → 14.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +112 -43
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/AsyncMotionValueAnimation.mjs +19 -33
- package/dist/es/animation/AsyncMotionValueAnimation.mjs.map +1 -1
- package/dist/es/animation/FollowAnimation.mjs +5 -0
- package/dist/es/animation/FollowAnimation.mjs.map +1 -1
- package/dist/es/animation/JSAnimation.mjs +7 -2
- package/dist/es/animation/JSAnimation.mjs.map +1 -1
- package/dist/es/animation/utils/resolve-start-time.mjs +17 -0
- package/dist/es/animation/utils/resolve-start-time.mjs.map +1 -0
- package/dist/es/index.mjs +1 -0
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/layout/animate-layout.mjs +19 -0
- package/dist/es/layout/animate-layout.mjs.map +1 -0
- package/dist/es/projection/node/create-projection-node.mjs +33 -8
- package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
- package/dist/es/render/svg/utils/build-attrs.mjs +7 -0
- package/dist/es/render/svg/utils/build-attrs.mjs.map +1 -1
- package/dist/es/render/utils/animation-state.mjs +15 -0
- package/dist/es/render/utils/animation-state.mjs.map +1 -1
- package/dist/index.d.ts +32 -5
- package/dist/motion-dom.dev.js +111 -43
- package/dist/motion-dom.js +1 -1
- package/package.json +9 -3
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { buildHTMLStyles } from '../../html/utils/build-styles.mjs';
|
|
2
2
|
import { buildSVGPath } from './path.mjs';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Values rendered via style rather than as attributes. This must include
|
|
6
|
+
* every value WAAPI can accelerate, as WAAPI writes its final value to
|
|
7
|
+
* style, which would otherwise override later attribute writes.
|
|
8
|
+
*/
|
|
4
9
|
const cssStyleProperties = [
|
|
5
10
|
"transform",
|
|
6
11
|
"opacity",
|
|
12
|
+
"clipPath",
|
|
13
|
+
"filter",
|
|
7
14
|
"offsetDistance",
|
|
8
15
|
"offsetPath",
|
|
9
16
|
"offsetRotate",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-attrs.mjs","sources":["../../../../../src/render/svg/utils/build-attrs.ts"],"sourcesContent":["import type { MotionNodeOptions } from \"../../../node/types\"\nimport { buildHTMLStyles } from \"../../html/utils/build-styles\"\nimport { ResolvedValues } from \"../../types\"\nimport { SVGRenderState } from \"../types\"\nimport { buildSVGPath } from \"./path\"\n\nexport const cssStyleProperties = [\n \"transform\",\n \"opacity\",\n \"offsetDistance\",\n \"offsetPath\",\n \"offsetRotate\",\n \"offsetAnchor\",\n]\n\n/**\n * Build SVG visual attributes, like cx and style.transform\n */\nexport function buildSVGAttrs(\n state: SVGRenderState,\n {\n attrX,\n attrY,\n attrScale,\n pathLength,\n pathSpacing = 1,\n pathOffset = 0,\n // This is object creation, which we try to avoid per-frame.\n ...latest\n }: ResolvedValues,\n isSVGTag: boolean,\n transformTemplate?: MotionNodeOptions[\"transformTemplate\"],\n styleProp?: Record<string, any>\n) {\n buildHTMLStyles(state, latest, transformTemplate)\n\n /**\n * For svg tags we just want to make sure viewBox is animatable and treat all the styles\n * as normal HTML tags.\n */\n if (isSVGTag) {\n if (state.style.viewBox) {\n state.attrs.viewBox = state.style.viewBox\n }\n return\n }\n\n state.attrs = state.style\n state.style = {}\n const { attrs, style } = state\n\n for (const key of cssStyleProperties) {\n if (attrs[key] !== undefined) {\n style[key] = attrs[key]\n delete attrs[key]\n }\n }\n\n if (style.transform || attrs.transformOrigin) {\n style.transformOrigin = attrs.transformOrigin ?? \"50% 50%\"\n delete attrs.transformOrigin\n }\n\n if (style.transform) {\n /**\n * SVG's element transform-origin uses its own median as a reference.\n * Therefore, transformBox becomes a fill-box\n */\n style.transformBox = (styleProp?.transformBox as string) ?? \"fill-box\"\n delete attrs.transformBox\n }\n\n // Render attrX/attrY/attrScale as attributes\n if (attrX !== undefined) attrs.x = attrX\n if (attrY !== undefined) attrs.y = attrY\n if (attrScale !== undefined) attrs.scale = attrScale\n\n // Build SVG path if one has been defined\n if (pathLength !== undefined) {\n buildSVGPath(\n attrs,\n pathLength as number,\n pathSpacing as number,\n pathOffset as number,\n false\n )\n }\n}\n"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"build-attrs.mjs","sources":["../../../../../src/render/svg/utils/build-attrs.ts"],"sourcesContent":["import type { MotionNodeOptions } from \"../../../node/types\"\nimport { buildHTMLStyles } from \"../../html/utils/build-styles\"\nimport { ResolvedValues } from \"../../types\"\nimport { SVGRenderState } from \"../types\"\nimport { buildSVGPath } from \"./path\"\n\n/**\n * Values rendered via style rather than as attributes. This must include\n * every value WAAPI can accelerate, as WAAPI writes its final value to\n * style, which would otherwise override later attribute writes.\n */\nexport const cssStyleProperties = [\n \"transform\",\n \"opacity\",\n \"clipPath\",\n \"filter\",\n \"offsetDistance\",\n \"offsetPath\",\n \"offsetRotate\",\n \"offsetAnchor\",\n]\n\n/**\n * Build SVG visual attributes, like cx and style.transform\n */\nexport function buildSVGAttrs(\n state: SVGRenderState,\n {\n attrX,\n attrY,\n attrScale,\n pathLength,\n pathSpacing = 1,\n pathOffset = 0,\n // This is object creation, which we try to avoid per-frame.\n ...latest\n }: ResolvedValues,\n isSVGTag: boolean,\n transformTemplate?: MotionNodeOptions[\"transformTemplate\"],\n styleProp?: Record<string, any>\n) {\n buildHTMLStyles(state, latest, transformTemplate)\n\n /**\n * For svg tags we just want to make sure viewBox is animatable and treat all the styles\n * as normal HTML tags.\n */\n if (isSVGTag) {\n if (state.style.viewBox) {\n state.attrs.viewBox = state.style.viewBox\n }\n return\n }\n\n state.attrs = state.style\n state.style = {}\n const { attrs, style } = state\n\n for (const key of cssStyleProperties) {\n if (attrs[key] !== undefined) {\n style[key] = attrs[key]\n delete attrs[key]\n }\n }\n\n if (style.transform || attrs.transformOrigin) {\n style.transformOrigin = attrs.transformOrigin ?? \"50% 50%\"\n delete attrs.transformOrigin\n }\n\n if (style.transform) {\n /**\n * SVG's element transform-origin uses its own median as a reference.\n * Therefore, transformBox becomes a fill-box\n */\n style.transformBox = (styleProp?.transformBox as string) ?? \"fill-box\"\n delete attrs.transformBox\n }\n\n // Render attrX/attrY/attrScale as attributes\n if (attrX !== undefined) attrs.x = attrX\n if (attrY !== undefined) attrs.y = attrY\n if (attrScale !== undefined) attrs.scale = attrScale\n\n // Build SVG path if one has been defined\n if (pathLength !== undefined) {\n buildSVGPath(\n attrs,\n pathLength as number,\n pathSpacing as number,\n pathOffset as number,\n false\n )\n }\n}\n"],"names":[],"mappings":";;;AAMA;;;;AAIG;AACI,MAAM,kBAAkB,GAAG;IAC9B,WAAW;IACX,SAAS;IACT,UAAU;IACV,QAAQ;IACR,gBAAgB;IAChB,YAAY;IACZ,cAAc;IACd,cAAc;;AAGlB;;AAEG;AACG,SAAU,aAAa,CACzB,KAAqB,EACrB,EACI,KAAK,EACL,KAAK,EACL,SAAS,EACT,UAAU,EACV,WAAW,GAAG,CAAC,EACf,UAAU,GAAG,CAAC;AACd;AACA,GAAG,MAAM,EACI,EACjB,QAAiB,EACjB,iBAA0D,EAC1D,SAA+B,EAAA;AAE/B,IAAA,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,iBAAiB,CAAC;AAEjD;;;AAGG;IACH,IAAI,QAAQ,EAAE;AACV,QAAA,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE;YACrB,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO;QAC7C;QACA;IACJ;AAEA,IAAA,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK;AACzB,IAAA,KAAK,CAAC,KAAK,GAAG,EAAE;AAChB,IAAA,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,KAAK;AAE9B,IAAA,KAAK,MAAM,GAAG,IAAI,kBAAkB,EAAE;AAClC,QAAA,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE;YAC1B,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC;AACvB,YAAA,OAAO,KAAK,CAAC,GAAG,CAAC;QACrB;IACJ;IAEA,IAAI,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,eAAe,EAAE;QAC1C,KAAK,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,IAAI,SAAS;QAC1D,OAAO,KAAK,CAAC,eAAe;IAChC;AAEA,IAAA,IAAI,KAAK,CAAC,SAAS,EAAE;AACjB;;;AAGG;QACH,KAAK,CAAC,YAAY,GAAI,SAAS,EAAE,YAAuB,IAAI,UAAU;QACtE,OAAO,KAAK,CAAC,YAAY;IAC7B;;IAGA,IAAI,KAAK,KAAK,SAAS;AAAE,QAAA,KAAK,CAAC,CAAC,GAAG,KAAK;IACxC,IAAI,KAAK,KAAK,SAAS;AAAE,QAAA,KAAK,CAAC,CAAC,GAAG,KAAK;IACxC,IAAI,SAAS,KAAK,SAAS;AAAE,QAAA,KAAK,CAAC,KAAK,GAAG,SAAS;;AAGpD,IAAA,IAAI,UAAU,KAAK,SAAS,EAAE;QAC1B,YAAY,CACR,KAAK,EACL,UAAoB,EACpB,WAAqB,EACrB,UAAoB,EACpB,KAAK,CACR;IACL;AACJ;;;;"}
|
|
@@ -195,6 +195,21 @@ function createAnimationState(visualElement) {
|
|
|
195
195
|
: visualElement.initialValues[key] === undefined
|
|
196
196
|
? visualElement.baseTarget[key]
|
|
197
197
|
: undefined) ?? null;
|
|
198
|
+
/**
|
|
199
|
+
* If it stays where it is, that's now its base. Otherwise a
|
|
200
|
+
* later removal (like a gesture ending) would also stay,
|
|
201
|
+
* leaving the value stuck. Stop first so accelerated
|
|
202
|
+
* animations sync the value they reached. In practice initial
|
|
203
|
+
* only changes like this with Fast Refresh, so this is
|
|
204
|
+
* dev-only (#3787).
|
|
205
|
+
*/
|
|
206
|
+
if (process.env.NODE_ENV !== "production" &&
|
|
207
|
+
fallbackAnimation[key] === null &&
|
|
208
|
+
visualElement.initialValues[key] !== undefined) {
|
|
209
|
+
delete visualElement.initialValues[key];
|
|
210
|
+
motionValue?.stop();
|
|
211
|
+
visualElement.baseTarget[key] = motionValue?.get();
|
|
212
|
+
}
|
|
198
213
|
});
|
|
199
214
|
animations.push({ animation: fallbackAnimation });
|
|
200
215
|
}
|
|
@@ -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 { isMotionValue } from \"../../value/utils/is-motion-value\"\nimport { isAnimationControls } from \"./is-animation-controls\"\nimport { isVariantLabel } from \"./is-variant-label\"\nimport { getTypeCustom, 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\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\nconst reversePriorityOrder = [...variantPriorityOrder].reverse()\n\n/**\n * Diffs the element's animation props (one layer per AnimationType, highest\n * priority wins each value) against the previous call and starts animations\n * for what changed.\n *\n * Uses `any` type for visualElement to avoid circular dependencies. It reads\n * props, parent, presenceContext, variantChildren, enteringChildren,\n * manuallyAnimateOnMount, blockInitialAnimation, getValue(),\n * getBaseTargetFromProps(), baseTarget and initialValues.\n */\nexport function createAnimationState(visualElement: any): AnimationState {\n let animate: AnimateFunction = (animations) =>\n Promise.all(\n animations.map(({ animation, options }) =>\n animateVisualElement(visualElement, animation, options)\n )\n )\n let state = createState()\n let isInitialRender = true\n\n /**\n * After a reset (StrictMode, Suspense, AnimatePresence re-entry) the next\n * animateChanges() mounts again, but initial={false} no longer applies.\n */\n let wasReset = false\n\n function animateChanges(changedActiveType?: AnimationType) {\n const { props, parent, manuallyAnimateOnMount } = visualElement\n const isMounting = isInitialRender || wasReset\n const animations: DefinitionAndOptions[] = []\n\n /**\n * Values removed from a type. A lower-priority type that defines\n * them animates them back, otherwise they fall back to a base target.\n */\n const removedKeys = new Set<string>()\n\n /**\n * Values claimed by active, higher-priority types.\n */\n let encounteredKeys: { [key: string]: any } = {}\n\n /**\n * Once a type has been deactivated, lower-priority variant labels\n * re-animate so variant children animate back too.\n */\n let removedVariantIndex = Infinity\n\n /**\n * Variant labels are inherited from the closest variant-controlling\n * ancestor, unless an element on the way has inherit={false}.\n */\n let source = visualElement\n do source = source.props.inherit !== false && source.parent\n while (source && !source.isControllingVariants)\n\n reversePriorityOrder.forEach((type, i) => {\n const typeState = state[type]\n const ownProp = props[type]\n const inheritedProp = source && source.props[type]\n const prop =\n ownProp !== undefined\n ? ownProp\n : isVariantLabel(inheritedProp) || inheritedProp === false\n ? inheritedProp\n : undefined\n const propIsVariant = isVariantLabel(prop)\n const activeDelta =\n type === changedActiveType ? typeState.isActive : null\n\n if (activeDelta === false) removedVariantIndex = i\n\n /**\n * Inherited labels are animated by the parent through\n * variantChildren, unless this element mounted after its parent.\n */\n const isInherited =\n propIsVariant &&\n ownProp === undefined &&\n !(isMounting && manuallyAnimateOnMount)\n\n typeState.protectedKeys = { ...encounteredKeys }\n\n if (\n (!typeState.isActive && activeDelta === null) ||\n (!prop && !typeState.prevProp) ||\n isAnimationControls(prop) ||\n typeof prop === \"boolean\"\n ) {\n return\n }\n\n /**\n * Don't re-resolve a running exit: a changed custom would start\n * new value animations that stop the originals, leaving the exit\n * promise unresolved and the element stuck in the DOM.\n */\n if (type === \"exit\" && typeState.isActive && activeDelta !== true) {\n encounteredKeys = {\n ...encounteredKeys,\n ...typeState.prevResolvedValues,\n }\n return\n }\n\n const variantDidChange = checkVariantsDidChange(\n typeState.prevProp,\n prop\n )\n let shouldAnimateType =\n variantDidChange ||\n (propIsVariant &&\n ((activeDelta && !isInherited) || i > removedVariantIndex))\n let handledRemovedValues = false\n const definitionList = Array.isArray(prop) ? prop : [prop]\n let resolvedValues: { [key: string]: any } = {}\n\n if (activeDelta !== false) {\n for (const definition of definitionList) {\n const { transition, transitionEnd, ...target } =\n resolveVariant(\n visualElement,\n definition,\n getTypeCustom(visualElement, type)\n ) || {}\n resolvedValues = {\n ...resolvedValues,\n ...target,\n ...transitionEnd,\n }\n }\n }\n\n const { prevResolvedValues } = typeState\n\n for (const key in { ...prevResolvedValues, ...resolvedValues }) {\n if (key in encounteredKeys) continue\n\n const next = resolvedValues[key]\n const prev = prevResolvedValues[key]\n\n /**\n * Keyframes compare by value, but replay whenever the\n * variant label changed.\n */\n const valueHasChanged =\n Array.isArray(next) && Array.isArray(prev)\n ? !shallowCompare(next, prev) || variantDidChange\n : next !== prev\n\n if (\n valueHasChanged &&\n (next === undefined || next === null)\n ) {\n removedKeys.add(key)\n } else if (\n valueHasChanged ||\n (next !== undefined && removedKeys.has(key))\n ) {\n shouldAnimateType = true\n if (removedKeys.delete(key)) handledRemovedValues = true\n typeState.needsAnimating[key] = true\n\n const motionValue = visualElement.getValue(key)\n if (motionValue) motionValue.liveStyle = false\n } else {\n typeState.protectedKeys[key] = true\n }\n }\n\n typeState.prevProp = prop\n typeState.prevResolvedValues = resolvedValues\n\n if (typeState.isActive) {\n encounteredKeys = { ...encounteredKeys, ...resolvedValues }\n }\n\n if (\n shouldAnimateType &&\n (!(isInherited && variantDidChange) || handledRemovedValues)\n ) {\n for (const animation of definitionList) {\n const options: VisualElementAnimationOptions = { type }\n\n /**\n * Elements that mount into an already-mounted parent\n * animate themselves, staggered by the parent variant's\n * delayChildren.\n */\n if (\n typeof animation === \"string\" &&\n isMounting &&\n manuallyAnimateOnMount &&\n parent?.enteringChildren\n ) {\n const delayChildren = resolveVariant(parent, animation)\n ?.transition?.delayChildren\n\n options.delay = calcChildStagger(\n parent.enteringChildren,\n visualElement,\n delayChildren\n )\n }\n\n animations.push({ animation, options })\n }\n }\n })\n\n /**\n * Removed values that no lower-priority type defines animate back to\n * initial, then style, then the value as first read. If initial no\n * longer defines a value it once did, it stays where it is.\n */\n if (removedKeys.size) {\n const { initial } = props\n const fallbackAnimation: { [key: string]: any } = {}\n const resolvedInitial =\n typeof initial !== \"boolean\" &&\n resolveVariant(\n visualElement,\n Array.isArray(initial) ? initial[0] : initial,\n visualElement.presenceContext?.custom\n )\n\n if (resolvedInitial && resolvedInitial.transition) {\n fallbackAnimation.transition = resolvedInitial.transition\n }\n\n removedKeys.forEach((key) => {\n const motionValue = visualElement.getValue(key)\n if (motionValue) motionValue.liveStyle = true\n\n const fromInitial =\n resolvedInitial && !Array.isArray(initial)\n ? (resolvedInitial as any)[key]\n : undefined\n const fromProps = visualElement.getBaseTargetFromProps(\n props,\n key\n )\n\n fallbackAnimation[key] =\n (fromInitial !== undefined\n ? fromInitial\n : fromProps !== undefined && !isMotionValue(fromProps)\n ? fromProps\n : visualElement.initialValues[key] === undefined\n ? visualElement.baseTarget[key]\n : undefined) ?? null\n })\n\n animations.push({ animation: fallbackAnimation })\n }\n\n const blockAnimation =\n (isMounting && visualElement.blockInitialAnimation) ||\n (isInitialRender &&\n !manuallyAnimateOnMount &&\n (props.initial === false || props.initial === props.animate))\n\n isInitialRender = wasReset = false\n\n return !blockAnimation && animations.length\n ? animate(animations)\n : Promise.resolve()\n }\n\n /**\n * Change whether a certain animation type is active.\n */\n function setActive(type: AnimationType, isActive: boolean) {\n if (state[type].isActive === isActive) return Promise.resolve()\n\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 AnimationType].protectedKeys = {}\n }\n\n return animations\n }\n\n return {\n animateChanges,\n setActive,\n /**\n * Allows tests to inject a mocked animate function.\n * @internal\n */\n setAnimateFunction: (makeAnimator) => {\n animate = makeAnimator(visualElement)\n },\n getState: () => state,\n reset: () => {\n state = createState()\n wasReset = 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 createState() {\n const state = {} as { [K in AnimationType]: AnimationTypeState }\n\n for (const type of variantPriorityOrder) {\n state[type] = {\n isActive: type === \"animate\",\n protectedKeys: {},\n needsAnimating: {},\n prevResolvedValues: {},\n }\n }\n\n return state\n}\n"],"names":[],"mappings":";;;;;;;;;AA2CA,MAAM,oBAAoB,GAAG,CAAC,GAAG,oBAAoB,CAAC,CAAC,OAAO,EAAE;AAEhE;;;;;;;;;AASG;AACG,SAAU,oBAAoB,CAAC,aAAkB,EAAA;AACnD,IAAA,IAAI,OAAO,GAAoB,CAAC,UAAU,KACtC,OAAO,CAAC,GAAG,CACP,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,KAClC,oBAAoB,CAAC,aAAa,EAAE,SAAS,EAAE,OAAO,CAAC,CAC1D,CACJ;AACL,IAAA,IAAI,KAAK,GAAG,WAAW,EAAE;IACzB,IAAI,eAAe,GAAG,IAAI;AAE1B;;;AAG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AACjB,YAAA,cAAc,EAAE,EAAE;AAClB,YAAA,kBAAkB,EAAE,EAAE;SACzB;IACL;AAEA,IAAA,OAAO,KAAK;AAChB;;;;"}
|
|
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 { isMotionValue } from \"../../value/utils/is-motion-value\"\nimport { isAnimationControls } from \"./is-animation-controls\"\nimport { isVariantLabel } from \"./is-variant-label\"\nimport { getTypeCustom, 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\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\nconst reversePriorityOrder = [...variantPriorityOrder].reverse()\n\n/**\n * Diffs the element's animation props (one layer per AnimationType, highest\n * priority wins each value) against the previous call and starts animations\n * for what changed.\n *\n * Uses `any` type for visualElement to avoid circular dependencies. It reads\n * props, parent, presenceContext, variantChildren, enteringChildren,\n * manuallyAnimateOnMount, blockInitialAnimation, getValue(),\n * getBaseTargetFromProps(), baseTarget and initialValues.\n */\nexport function createAnimationState(visualElement: any): AnimationState {\n let animate: AnimateFunction = (animations) =>\n Promise.all(\n animations.map(({ animation, options }) =>\n animateVisualElement(visualElement, animation, options)\n )\n )\n let state = createState()\n let isInitialRender = true\n\n /**\n * After a reset (StrictMode, Suspense, AnimatePresence re-entry) the next\n * animateChanges() mounts again, but initial={false} no longer applies.\n */\n let wasReset = false\n\n function animateChanges(changedActiveType?: AnimationType) {\n const { props, parent, manuallyAnimateOnMount } = visualElement\n const isMounting = isInitialRender || wasReset\n const animations: DefinitionAndOptions[] = []\n\n /**\n * Values removed from a type. A lower-priority type that defines\n * them animates them back, otherwise they fall back to a base target.\n */\n const removedKeys = new Set<string>()\n\n /**\n * Values claimed by active, higher-priority types.\n */\n let encounteredKeys: { [key: string]: any } = {}\n\n /**\n * Once a type has been deactivated, lower-priority variant labels\n * re-animate so variant children animate back too.\n */\n let removedVariantIndex = Infinity\n\n /**\n * Variant labels are inherited from the closest variant-controlling\n * ancestor, unless an element on the way has inherit={false}.\n */\n let source = visualElement\n do source = source.props.inherit !== false && source.parent\n while (source && !source.isControllingVariants)\n\n reversePriorityOrder.forEach((type, i) => {\n const typeState = state[type]\n const ownProp = props[type]\n const inheritedProp = source && source.props[type]\n const prop =\n ownProp !== undefined\n ? ownProp\n : isVariantLabel(inheritedProp) || inheritedProp === false\n ? inheritedProp\n : undefined\n const propIsVariant = isVariantLabel(prop)\n const activeDelta =\n type === changedActiveType ? typeState.isActive : null\n\n if (activeDelta === false) removedVariantIndex = i\n\n /**\n * Inherited labels are animated by the parent through\n * variantChildren, unless this element mounted after its parent.\n */\n const isInherited =\n propIsVariant &&\n ownProp === undefined &&\n !(isMounting && manuallyAnimateOnMount)\n\n typeState.protectedKeys = { ...encounteredKeys }\n\n if (\n (!typeState.isActive && activeDelta === null) ||\n (!prop && !typeState.prevProp) ||\n isAnimationControls(prop) ||\n typeof prop === \"boolean\"\n ) {\n return\n }\n\n /**\n * Don't re-resolve a running exit: a changed custom would start\n * new value animations that stop the originals, leaving the exit\n * promise unresolved and the element stuck in the DOM.\n */\n if (type === \"exit\" && typeState.isActive && activeDelta !== true) {\n encounteredKeys = {\n ...encounteredKeys,\n ...typeState.prevResolvedValues,\n }\n return\n }\n\n const variantDidChange = checkVariantsDidChange(\n typeState.prevProp,\n prop\n )\n let shouldAnimateType =\n variantDidChange ||\n (propIsVariant &&\n ((activeDelta && !isInherited) || i > removedVariantIndex))\n let handledRemovedValues = false\n const definitionList = Array.isArray(prop) ? prop : [prop]\n let resolvedValues: { [key: string]: any } = {}\n\n if (activeDelta !== false) {\n for (const definition of definitionList) {\n const { transition, transitionEnd, ...target } =\n resolveVariant(\n visualElement,\n definition,\n getTypeCustom(visualElement, type)\n ) || {}\n resolvedValues = {\n ...resolvedValues,\n ...target,\n ...transitionEnd,\n }\n }\n }\n\n const { prevResolvedValues } = typeState\n\n for (const key in { ...prevResolvedValues, ...resolvedValues }) {\n if (key in encounteredKeys) continue\n\n const next = resolvedValues[key]\n const prev = prevResolvedValues[key]\n\n /**\n * Keyframes compare by value, but replay whenever the\n * variant label changed.\n */\n const valueHasChanged =\n Array.isArray(next) && Array.isArray(prev)\n ? !shallowCompare(next, prev) || variantDidChange\n : next !== prev\n\n if (\n valueHasChanged &&\n (next === undefined || next === null)\n ) {\n removedKeys.add(key)\n } else if (\n valueHasChanged ||\n (next !== undefined && removedKeys.has(key))\n ) {\n shouldAnimateType = true\n if (removedKeys.delete(key)) handledRemovedValues = true\n typeState.needsAnimating[key] = true\n\n const motionValue = visualElement.getValue(key)\n if (motionValue) motionValue.liveStyle = false\n } else {\n typeState.protectedKeys[key] = true\n }\n }\n\n typeState.prevProp = prop\n typeState.prevResolvedValues = resolvedValues\n\n if (typeState.isActive) {\n encounteredKeys = { ...encounteredKeys, ...resolvedValues }\n }\n\n if (\n shouldAnimateType &&\n (!(isInherited && variantDidChange) || handledRemovedValues)\n ) {\n for (const animation of definitionList) {\n const options: VisualElementAnimationOptions = { type }\n\n /**\n * Elements that mount into an already-mounted parent\n * animate themselves, staggered by the parent variant's\n * delayChildren.\n */\n if (\n typeof animation === \"string\" &&\n isMounting &&\n manuallyAnimateOnMount &&\n parent?.enteringChildren\n ) {\n const delayChildren = resolveVariant(parent, animation)\n ?.transition?.delayChildren\n\n options.delay = calcChildStagger(\n parent.enteringChildren,\n visualElement,\n delayChildren\n )\n }\n\n animations.push({ animation, options })\n }\n }\n })\n\n /**\n * Removed values that no lower-priority type defines animate back to\n * initial, then style, then the value as first read. If initial no\n * longer defines a value it once did, it stays where it is.\n */\n if (removedKeys.size) {\n const { initial } = props\n const fallbackAnimation: { [key: string]: any } = {}\n const resolvedInitial =\n typeof initial !== \"boolean\" &&\n resolveVariant(\n visualElement,\n Array.isArray(initial) ? initial[0] : initial,\n visualElement.presenceContext?.custom\n )\n\n if (resolvedInitial && resolvedInitial.transition) {\n fallbackAnimation.transition = resolvedInitial.transition\n }\n\n removedKeys.forEach((key) => {\n const motionValue = visualElement.getValue(key)\n if (motionValue) motionValue.liveStyle = true\n\n const fromInitial =\n resolvedInitial && !Array.isArray(initial)\n ? (resolvedInitial as any)[key]\n : undefined\n const fromProps = visualElement.getBaseTargetFromProps(\n props,\n key\n )\n\n fallbackAnimation[key] =\n (fromInitial !== undefined\n ? fromInitial\n : fromProps !== undefined && !isMotionValue(fromProps)\n ? fromProps\n : visualElement.initialValues[key] === undefined\n ? visualElement.baseTarget[key]\n : undefined) ?? null\n\n /**\n * If it stays where it is, that's now its base. Otherwise a\n * later removal (like a gesture ending) would also stay,\n * leaving the value stuck. Stop first so accelerated\n * animations sync the value they reached. In practice initial\n * only changes like this with Fast Refresh, so this is\n * dev-only (#3787).\n */\n if (\n process.env.NODE_ENV !== \"production\" &&\n fallbackAnimation[key] === null &&\n visualElement.initialValues[key] !== undefined\n ) {\n delete visualElement.initialValues[key]\n motionValue?.stop()\n visualElement.baseTarget[key] = motionValue?.get()\n }\n })\n\n animations.push({ animation: fallbackAnimation })\n }\n\n const blockAnimation =\n (isMounting && visualElement.blockInitialAnimation) ||\n (isInitialRender &&\n !manuallyAnimateOnMount &&\n (props.initial === false || props.initial === props.animate))\n\n isInitialRender = wasReset = false\n\n return !blockAnimation && animations.length\n ? animate(animations)\n : Promise.resolve()\n }\n\n /**\n * Change whether a certain animation type is active.\n */\n function setActive(type: AnimationType, isActive: boolean) {\n if (state[type].isActive === isActive) return Promise.resolve()\n\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 AnimationType].protectedKeys = {}\n }\n\n return animations\n }\n\n return {\n animateChanges,\n setActive,\n /**\n * Allows tests to inject a mocked animate function.\n * @internal\n */\n setAnimateFunction: (makeAnimator) => {\n animate = makeAnimator(visualElement)\n },\n getState: () => state,\n reset: () => {\n state = createState()\n wasReset = 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 createState() {\n const state = {} as { [K in AnimationType]: AnimationTypeState }\n\n for (const type of variantPriorityOrder) {\n state[type] = {\n isActive: type === \"animate\",\n protectedKeys: {},\n needsAnimating: {},\n prevResolvedValues: {},\n }\n }\n\n return state\n}\n"],"names":[],"mappings":";;;;;;;;;AA2CA,MAAM,oBAAoB,GAAG,CAAC,GAAG,oBAAoB,CAAC,CAAC,OAAO,EAAE;AAEhE;;;;;;;;;AASG;AACG,SAAU,oBAAoB,CAAC,aAAkB,EAAA;AACnD,IAAA,IAAI,OAAO,GAAoB,CAAC,UAAU,KACtC,OAAO,CAAC,GAAG,CACP,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,SA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G,IAAI;QACnB,CAAC;KACJ;AACL;AAEM,SAAU,sBAAsB,CAAC,IAAS,EAAE,IAAS,EAAA;AACvD,IAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC1B,OAAO,IAAI,KAAK,IAAI;IACxB;AAAO,SAAA,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;AAC5B,QAAA,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC;IACtC;AAEA,IAAA,OAAO,KAAK;AAChB;AAUA,SAAS,WAAW,GAAA;IAChB,MAAM,KAAK,GAAG,EAAkD;AAEhE,IAAA,KAAK,MAAM,IAAI,IAAI,oBAAoB,EAAE;QACrC,KAAK,CAAC,IAAI,CAAC,GAAG;YACV,QAAQ,EAAE,IAAI,KAAK,SAAS;AAC5B,YAAA,aAAa,EAAE,EAAE;AACjB,YAAA,cAAc,EAAE,EAAE;AAClB,YAAA,kBAAkB,EAAE,EAAE;SACzB;IACL;AAEA,IAAA,OAAO,KAAK;AAChB;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2803,6 +2803,10 @@ declare class JSAnimation<T extends number | string> extends WithPromise impleme
|
|
|
2803
2803
|
*/
|
|
2804
2804
|
private driver?;
|
|
2805
2805
|
private isStopped;
|
|
2806
|
+
/**
|
|
2807
|
+
* The start time this animation picked for itself, until its first tick.
|
|
2808
|
+
*/
|
|
2809
|
+
private pendingStartTime?;
|
|
2806
2810
|
private generator;
|
|
2807
2811
|
private calculatedDuration;
|
|
2808
2812
|
private resolvedDuration;
|
|
@@ -4709,6 +4713,8 @@ interface IProjectionNode<I = unknown> {
|
|
|
4709
4713
|
options: ProjectionNodeOptions;
|
|
4710
4714
|
setOptions(options: ProjectionNodeOptions): void;
|
|
4711
4715
|
layout?: Measurements;
|
|
4716
|
+
dragSnapshot?: Measurements;
|
|
4717
|
+
dragAncestor?: IProjectionNode;
|
|
4712
4718
|
snapshot?: Measurements;
|
|
4713
4719
|
target?: Box;
|
|
4714
4720
|
relativeTarget?: Box;
|
|
@@ -4769,7 +4775,6 @@ interface IProjectionNode<I = unknown> {
|
|
|
4769
4775
|
currentAnimation?: JSAnimation<number>;
|
|
4770
4776
|
isTreeAnimating?: boolean;
|
|
4771
4777
|
isAnimationBlocked?: boolean;
|
|
4772
|
-
isTreeAnimationBlocked: () => boolean;
|
|
4773
4778
|
setAnimationOrigin(delta: Delta, hasOnlyRelativeTargetChanged?: boolean, pathFn?: MotionPath): void;
|
|
4774
4779
|
startAnimation(transition: ValueTransition): void;
|
|
4775
4780
|
finishAnimation(): void;
|
|
@@ -4904,6 +4909,15 @@ declare function createProjectionNode<I>({ attachResizeListener, defaultParent,
|
|
|
4904
4909
|
* captured with all parent scrolls and projection transforms unset.
|
|
4905
4910
|
*/
|
|
4906
4911
|
layout: Measurements | undefined;
|
|
4912
|
+
/**
|
|
4913
|
+
* A measurement taken just before the current update of a dragged node
|
|
4914
|
+
* without a snapshot (one without `layout`).
|
|
4915
|
+
*/
|
|
4916
|
+
dragSnapshot: Measurements | undefined;
|
|
4917
|
+
/**
|
|
4918
|
+
* The nearest dragged ancestor, recorded in willUpdate.
|
|
4919
|
+
*/
|
|
4920
|
+
dragAncestor: IProjectionNode | undefined;
|
|
4907
4921
|
/**
|
|
4908
4922
|
* The layout used to calculate the previous layout animation. We use this to compare
|
|
4909
4923
|
* layouts between renders and decide whether we need to trigger a new layout animation
|
|
@@ -5072,7 +5086,6 @@ declare function createProjectionNode<I>({ attachResizeListener, defaultParent,
|
|
|
5072
5086
|
blockUpdate(): void;
|
|
5073
5087
|
unblockUpdate(): void;
|
|
5074
5088
|
isUpdateBlocked(): boolean;
|
|
5075
|
-
isTreeAnimationBlocked(): boolean;
|
|
5076
5089
|
startUpdate(): void;
|
|
5077
5090
|
getTransformTemplate(): TransformTemplate | undefined;
|
|
5078
5091
|
willUpdate(shouldNotifyListeners?: boolean): void;
|
|
@@ -5180,6 +5193,8 @@ declare const DocumentProjectionNode: {
|
|
|
5180
5193
|
options: ProjectionNodeOptions;
|
|
5181
5194
|
snapshot: Measurements | undefined;
|
|
5182
5195
|
layout: Measurements | undefined;
|
|
5196
|
+
dragSnapshot: Measurements | undefined;
|
|
5197
|
+
dragAncestor: IProjectionNode<unknown> | undefined;
|
|
5183
5198
|
targetLayout?: motion_utils.Box | undefined;
|
|
5184
5199
|
layoutCorrected: motion_utils.Box;
|
|
5185
5200
|
targetDelta?: motion_utils.Delta | undefined;
|
|
@@ -5224,7 +5239,6 @@ declare const DocumentProjectionNode: {
|
|
|
5224
5239
|
blockUpdate(): void;
|
|
5225
5240
|
unblockUpdate(): void;
|
|
5226
5241
|
isUpdateBlocked(): boolean;
|
|
5227
|
-
isTreeAnimationBlocked(): boolean;
|
|
5228
5242
|
startUpdate(): void;
|
|
5229
5243
|
getTransformTemplate(): TransformTemplate | undefined;
|
|
5230
5244
|
willUpdate(shouldNotifyListeners?: boolean): void;
|
|
@@ -5323,6 +5337,8 @@ declare const HTMLProjectionNode: {
|
|
|
5323
5337
|
options: ProjectionNodeOptions;
|
|
5324
5338
|
snapshot: Measurements | undefined;
|
|
5325
5339
|
layout: Measurements | undefined;
|
|
5340
|
+
dragSnapshot: Measurements | undefined;
|
|
5341
|
+
dragAncestor: IProjectionNode<unknown> | undefined;
|
|
5326
5342
|
targetLayout?: motion_utils.Box | undefined;
|
|
5327
5343
|
layoutCorrected: motion_utils.Box;
|
|
5328
5344
|
targetDelta?: motion_utils.Delta | undefined;
|
|
@@ -5367,7 +5383,6 @@ declare const HTMLProjectionNode: {
|
|
|
5367
5383
|
blockUpdate(): void;
|
|
5368
5384
|
unblockUpdate(): void;
|
|
5369
5385
|
isUpdateBlocked(): boolean;
|
|
5370
|
-
isTreeAnimationBlocked(): boolean;
|
|
5371
5386
|
startUpdate(): void;
|
|
5372
5387
|
getTransformTemplate(): TransformTemplate | undefined;
|
|
5373
5388
|
willUpdate(shouldNotifyListeners?: boolean): void;
|
|
@@ -5539,6 +5554,18 @@ declare function parseAnimateLayoutArgs(scopeOrUpdateDom: ElementOrSelector | ((
|
|
|
5539
5554
|
defaultOptions?: AnimationOptions;
|
|
5540
5555
|
};
|
|
5541
5556
|
|
|
5557
|
+
/**
|
|
5558
|
+
* Animate layout changes made within `updateDom` on elements tagged
|
|
5559
|
+
* with `data-layout` or `data-layout-id`.
|
|
5560
|
+
*
|
|
5561
|
+
* ```
|
|
5562
|
+
* animateLayout(() => {
|
|
5563
|
+
* element.style.justifyContent = "flex-end"
|
|
5564
|
+
* })
|
|
5565
|
+
* ```
|
|
5566
|
+
*/
|
|
5567
|
+
declare function animateLayout(scopeOrUpdateDom: ElementOrSelector | (() => void), updateDomOrOptions?: (() => void) | AnimationOptions, options?: AnimationOptions): LayoutAnimationBuilder;
|
|
5568
|
+
|
|
5542
5569
|
/**
|
|
5543
5570
|
* @deprecated
|
|
5544
5571
|
*
|
|
@@ -5552,4 +5579,4 @@ declare const sync: Batcher;
|
|
|
5552
5579
|
*/
|
|
5553
5580
|
declare const cancelSync: Record<string, (process: Process) => void>;
|
|
5554
5581
|
|
|
5555
|
-
export { type AccelerateConfig, type AcceptedAnimations, type ActiveStatsBuffer, type AddEffectValue, type AnimateEffect, type AnimationDefinition, type AnimationGeneratorName, type AnimationGeneratorType, type AnimationList, type AnimationOptions, type AnimationOrchestrationOptions, type AnimationPlaybackControls, type AnimationPlaybackControlsWithThen, type AnimationPlaybackLifecycles, type AnimationPlaybackOptions, type AnimationScope, type AnimationState$1 as AnimationState, type AnimationType, type AnimationTypeState, type AnyResolvedKeyframe, type ArcOptions, AsyncMotionValueAnimation, type Batcher, type CSSStyleDeclarationWithTransform, type CSSVariableName, type CSSVariableToken, type CancelProcess, type Color, type ComplexValueInfo, type ComplexValues, type DOMKeyframesDefinition, DOMKeyframesResolver, type DOMValueAnimationOptions, DOMVisualElement, type DOMVisualElementOptions, type DecayOptions, type DelayedFunction, DocumentProjectionNode, type DragElastic, type DragHandler, type DraggableProps, type DurationSpringOptions, type DynamicOption, type Effect, type EffectKeyframes, type EffectOptions, type EffectRead, type EffectTest, type EffectTransition, type ElementOrSelector, type EventInfo, type EventOptions, Feature, type FeatureClass, FlatTree, type FollowValueOptions, type FrameData, type GeneratorFactory, type GeneratorFactoryFunction, GroupAnimation, GroupAnimationWithThen, type GroupedAnimations, type HSLA, HTMLProjectionNode, type HTMLRenderState, HTMLVisualElement, type HandoffFunction, type IProjectionNode, type InactiveStatsBuffer, type InertiaOptions, type InitialPromotionConfig, type InterpolateOptions, JSAnimation, type KeyframeGenerator, type KeyframeOptions, KeyframeResolver, LayoutAnimationBuilder, type LayoutEvents, type LayoutLifecycles, type LayoutProjectionMetrics, type LayoutProjectionStats, type LayoutUpdateData, type LayoutUpdateHandler, type LegacyAnimationControls, type MapInputRange, type Measurements, type Mixer, type MixerFactory, type MotionConfigContextProps, type MotionNodeAdvancedOptions, type MotionNodeAnimationOptions, type MotionNodeDragHandlers, type MotionNodeDraggableOptions, type MotionNodeEventOptions, type MotionNodeFocusHandlers, type MotionNodeHoverHandlers, type MotionNodeLayoutOptions, type MotionNodeOptions, type MotionNodePanHandlers, type MotionNodeTapHandlers, type MotionNodeViewportOptions, type MotionPath, type MotionStyle, MotionValue, type MotionValueAnimation, type MotionValueEventCallbacks, type MotionValueOptions, MotionValueState, type MultiTransformer, NativeAnimation, NativeAnimationExtended, type NativeAnimationOptions, type NativeAnimationOptionsExtended, NativeAnimationWrapper, type NodeGroup, NodeStack, type NumberMap, ObjectVisualElement, type OnHoverEndEvent, type OnHoverStartEvent, type OnKeyframesResolved, type OnPressEndEvent, type OnPressStartEvent, type Owner, type PanHandler, type PanInfo, type PassiveEffect, type PathInterpolator, type PathState, type Phase, type Point2D, type PointerEventOptions, type PresenceContextProps, type PressGestureInfo, type Process, type ProgressTimeline, type ProjectionEventName, type ProjectionNodeConfig, type ProjectionNodeOptions, type PropagateOptions, type RGBA, type ReducedMotionConfig, type RepeatType, type ResolvedConstraints, type ResolvedElastic, type ResolvedKeyframes, type ResolvedValueKeyframe, type ResolvedValues$1 as ResolvedValues, type SVGAttributes, type SVGForcedAttrKeyframesDefinition, type SVGForcedAttrProperties, type SVGForcedAttrTransitions, type SVGKeyframesDefinition, type SVGPathKeyframesDefinition, type SVGPathProperties, type SVGPathTransitions, type SVGRenderState, type SVGTransitions, SVGVisualElement, type ScaleCorrectionNode, type ScaleCorrector, type ScaleCorrectorDefinition, type ScaleCorrectorMap, type Schedule, type ScrapeMotionValuesFromProps, type ScrollMeasurements, type SelectorCache, type SingleTransformer, type Spring, type SpringOptions, type StaggerOptions, type StaggerOrigin, type StartAnimation, type StatsRecording, type Step, type StepId, type Steps, type StyleKeyframesDefinition, type StyleSubject, type StyleTransitions, type Subscriber, type TapHandlers, type TapInfo, type Target, type TargetAndTransition, type TargetResolver, type TimelineWithFallback, type TransformInputRange, type TransformOptions, type TransformOrigin, type TransformProperties, type TransformTemplate, type Transformer, type Transition, type TransitionWithValueOverrides, type Tween, type UnresolvedKeyframes, type UnresolvedValueKeyframe, type UseRenderState, type ValueAnimationOptions, type ValueAnimationOptionsWithRenderContext, type ValueAnimationTransition, type ValueAnimationWithDynamicDelay, type ValueIndexes, type ValueKeyframe, type ValueKeyframesDefinition, type ValueTransformer, type ValueTransition, type ValueType, type ValueTypeMap, type VariableKeyframesDefinition, type VariableTransitions, type Variant, type VariantLabels, type Variants, type VelocityOptions, type ViewTransitionAnimationDefinition, ViewTransitionBuilder, type ViewTransitionOptions, type ViewTransitionTarget, type ViewTransitionTargetDefinition, type ViewportEventHandler, type ViewportOptions, VisualElement, type VisualElementAnimationOptions, type VisualElementEventCallbacks, type VisualElementOptions, type VisualState, type WillChange, type WithAppearProps, type WithDepth, type WithQuerySelectorAll, acceleratedValues, addAttrValue, addDomEvent, addEffect, addSVGValue, addScaleCorrector, addStyleValue, addValueToWillChange, alpha, analyseComplexValue, animateEffectSubject, animateElement, animateMotionValue, animateSingleValue, animateTarget, animateValue, animateValues, animateVariant, animateView, animateVisualElement, animationMapKey, applyAxisDelta, applyBoxDelta, applyGeneratorOptions, applyPointDelta, applyPxDefaults, applyTreeDeltas, arc, aspectRatio, attachFollow, attachSpring, attrEffect, axisDeltaEquals, axisEquals, axisEqualsRounded, boxEquals, boxEqualsRounded, buildHTMLStyles, buildProjectionTransform, buildSVGAttrs, buildSVGPath, buildTransform, calcAxisDelta, calcBoxDelta, calcChildStagger, calcGeneratorDuration, calcLength, calcRelativeAxis, calcRelativeAxisPosition, calcRelativeBox, calcRelativePosition, camelCaseAttributes, camelToDash, cancelFrame, cancelMicrotask, cancelSync, checkVariantsDidChange, cleanDirtyNodes, collectMotionValues, color, compareByDepth, complex, containsCSSVariable, convertBoundingBoxToBox, convertBoxToBoundingBox, convertOffsetToTimes, copyAxisDeltaInto, copyAxisInto, copyBoxInto, correctBorderRadius, correctBoxShadow, createAnimationState, createAxis, createAxisDelta, createBox, createDelta, createEffect, createGeneratorEasing, createProjectionNode, createRenderBatcher, cubicBezierAsString, defaultEasing, defaultOffset, defaultTransformValue, defaultValueTypes, degrees, delay, delayInSeconds, dimensionValueTypes, eachAxis, fillOffset, fillWildcards, findDimensionValueType, findEffect, findValueType, flushKeyframeResolvers, followValue, frame, frameData, frameSteps, generateLinearEasing, getAnimatableNone, getAnimationMap, getComputedStyle, getDefaultTransition, getDefaultValueType, getFeatureDefinitions, getFinalKeyframe, getMixer, getOptimisedAppearId, getOriginIndex, getValueAsType, getValueTransition, getVariableValue, getVariantContext, getViewAnimationLayerInfo, getViewAnimations, globalProjectionState, handOffElementState, has2DTranslate, hasComplexValues, hasReducedMotionListener, hasScale, hasTransform, hex, hover, hsla, hslaToRgba, inertia, initPrefersReducedMotion, interpolate, invisibleValues, isAnimationControls, isCSSVariableName, isCSSVariableToken, isControllingVariants, isDeltaZero, isDragActive, isDragging, isElementKeyboardAccessible, isElementTextInput, isForcedMotionValue, isGenerator, isHTMLElement, isKeyframesTarget, isMotionValue, isNear, isNodeOrChild, isPrimaryPointer, isSVGElement, isSVGSVGElement, isSVGTag, isTransitionDefined, isVariantLabel, isVariantNode, isWaapiSupportedEasing, isWillChangeMotionValue, keyframes, makeAnimationInstant, mapEasingToNativeEasing, mapValue, maxGeneratorDuration, measurePageBox, measureViewportBox, microtask, mix, mixArray, mixColor, mixComplex, mixImmediate, mixLinearColor, mixNumber, mixObject, mixValues, mixVisibility, motionValue, nodeGroup, number, numberValueTypes, optimizedAppearDataAttribute, optimizedAppearDataId, originProps, parseAnimateLayoutArgs, parseCSSVariable, parseValueFromTransform, percent, pixelsToPercent, positionalKeys, prefersReducedMotion, press, progressPercentage, propEffect, propagateDirtyNodes, px, readSVGValue, readStyleValue, readTransformValue, recordStats, removeAxisDelta, removeAxisTransforms, removeBoxTransforms, removeEffect, removePointDelta, renderHTML, renderSVG, resize, resolveElements, resolveMotionValue, resolveTransition, resolveVariant, resolveVariantFromProps, rgbUnit, rgba, rootProjectionNode, scale, scaleCorrectors, scalePoint, scrapeMotionValuesFromProps$1 as scrapeHTMLMotionValuesFromProps, scrapeMotionValuesFromProps as scrapeSVGMotionValuesFromProps, setDragLock, setFeatureDefinitions, setStyle, setTarget, spring, springValue, stagger, startWaapiAnimation, statsBuffer, styleEffect, styleSubjectEffect, supportedWaapiEasing, supportsBrowserAnimation, supportsFlags, supportsLinearEasing, supportsPartialKeyframes, supportsScrollTimeline, supportsViewTimeline, svgEffect, svgSubjectEffect, sync, testValueType, time, transform, transformAxis, transformBox, transformBoxPoints, transformPropOrder, transformProps, transformValue, transformValueTypes, translateAxis, updateMotionValuesFromProps, variantPriorityOrder, variantProps, vh, visualElementStore, vw };
|
|
5582
|
+
export { type AccelerateConfig, type AcceptedAnimations, type ActiveStatsBuffer, type AddEffectValue, type AnimateEffect, type AnimationDefinition, type AnimationGeneratorName, type AnimationGeneratorType, type AnimationList, type AnimationOptions, type AnimationOrchestrationOptions, type AnimationPlaybackControls, type AnimationPlaybackControlsWithThen, type AnimationPlaybackLifecycles, type AnimationPlaybackOptions, type AnimationScope, type AnimationState$1 as AnimationState, type AnimationType, type AnimationTypeState, type AnyResolvedKeyframe, type ArcOptions, AsyncMotionValueAnimation, type Batcher, type CSSStyleDeclarationWithTransform, type CSSVariableName, type CSSVariableToken, type CancelProcess, type Color, type ComplexValueInfo, type ComplexValues, type DOMKeyframesDefinition, DOMKeyframesResolver, type DOMValueAnimationOptions, DOMVisualElement, type DOMVisualElementOptions, type DecayOptions, type DelayedFunction, DocumentProjectionNode, type DragElastic, type DragHandler, type DraggableProps, type DurationSpringOptions, type DynamicOption, type Effect, type EffectKeyframes, type EffectOptions, type EffectRead, type EffectTest, type EffectTransition, type ElementOrSelector, type EventInfo, type EventOptions, Feature, type FeatureClass, FlatTree, type FollowValueOptions, type FrameData, type GeneratorFactory, type GeneratorFactoryFunction, GroupAnimation, GroupAnimationWithThen, type GroupedAnimations, type HSLA, HTMLProjectionNode, type HTMLRenderState, HTMLVisualElement, type HandoffFunction, type IProjectionNode, type InactiveStatsBuffer, type InertiaOptions, type InitialPromotionConfig, type InterpolateOptions, JSAnimation, type KeyframeGenerator, type KeyframeOptions, KeyframeResolver, LayoutAnimationBuilder, type LayoutEvents, type LayoutLifecycles, type LayoutProjectionMetrics, type LayoutProjectionStats, type LayoutUpdateData, type LayoutUpdateHandler, type LegacyAnimationControls, type MapInputRange, type Measurements, type Mixer, type MixerFactory, type MotionConfigContextProps, type MotionNodeAdvancedOptions, type MotionNodeAnimationOptions, type MotionNodeDragHandlers, type MotionNodeDraggableOptions, type MotionNodeEventOptions, type MotionNodeFocusHandlers, type MotionNodeHoverHandlers, type MotionNodeLayoutOptions, type MotionNodeOptions, type MotionNodePanHandlers, type MotionNodeTapHandlers, type MotionNodeViewportOptions, type MotionPath, type MotionStyle, MotionValue, type MotionValueAnimation, type MotionValueEventCallbacks, type MotionValueOptions, MotionValueState, type MultiTransformer, NativeAnimation, NativeAnimationExtended, type NativeAnimationOptions, type NativeAnimationOptionsExtended, NativeAnimationWrapper, type NodeGroup, NodeStack, type NumberMap, ObjectVisualElement, type OnHoverEndEvent, type OnHoverStartEvent, type OnKeyframesResolved, type OnPressEndEvent, type OnPressStartEvent, type Owner, type PanHandler, type PanInfo, type PassiveEffect, type PathInterpolator, type PathState, type Phase, type Point2D, type PointerEventOptions, type PresenceContextProps, type PressGestureInfo, type Process, type ProgressTimeline, type ProjectionEventName, type ProjectionNodeConfig, type ProjectionNodeOptions, type PropagateOptions, type RGBA, type ReducedMotionConfig, type RepeatType, type ResolvedConstraints, type ResolvedElastic, type ResolvedKeyframes, type ResolvedValueKeyframe, type ResolvedValues$1 as ResolvedValues, type SVGAttributes, type SVGForcedAttrKeyframesDefinition, type SVGForcedAttrProperties, type SVGForcedAttrTransitions, type SVGKeyframesDefinition, type SVGPathKeyframesDefinition, type SVGPathProperties, type SVGPathTransitions, type SVGRenderState, type SVGTransitions, SVGVisualElement, type ScaleCorrectionNode, type ScaleCorrector, type ScaleCorrectorDefinition, type ScaleCorrectorMap, type Schedule, type ScrapeMotionValuesFromProps, type ScrollMeasurements, type SelectorCache, type SingleTransformer, type Spring, type SpringOptions, type StaggerOptions, type StaggerOrigin, type StartAnimation, type StatsRecording, type Step, type StepId, type Steps, type StyleKeyframesDefinition, type StyleSubject, type StyleTransitions, type Subscriber, type TapHandlers, type TapInfo, type Target, type TargetAndTransition, type TargetResolver, type TimelineWithFallback, type TransformInputRange, type TransformOptions, type TransformOrigin, type TransformProperties, type TransformTemplate, type Transformer, type Transition, type TransitionWithValueOverrides, type Tween, type UnresolvedKeyframes, type UnresolvedValueKeyframe, type UseRenderState, type ValueAnimationOptions, type ValueAnimationOptionsWithRenderContext, type ValueAnimationTransition, type ValueAnimationWithDynamicDelay, type ValueIndexes, type ValueKeyframe, type ValueKeyframesDefinition, type ValueTransformer, type ValueTransition, type ValueType, type ValueTypeMap, type VariableKeyframesDefinition, type VariableTransitions, type Variant, type VariantLabels, type Variants, type VelocityOptions, type ViewTransitionAnimationDefinition, ViewTransitionBuilder, type ViewTransitionOptions, type ViewTransitionTarget, type ViewTransitionTargetDefinition, type ViewportEventHandler, type ViewportOptions, VisualElement, type VisualElementAnimationOptions, type VisualElementEventCallbacks, type VisualElementOptions, type VisualState, type WillChange, type WithAppearProps, type WithDepth, type WithQuerySelectorAll, acceleratedValues, addAttrValue, addDomEvent, addEffect, addSVGValue, addScaleCorrector, addStyleValue, addValueToWillChange, alpha, analyseComplexValue, animateEffectSubject, animateElement, animateLayout, animateMotionValue, animateSingleValue, animateTarget, animateValue, animateValues, animateVariant, animateView, animateVisualElement, animationMapKey, applyAxisDelta, applyBoxDelta, applyGeneratorOptions, applyPointDelta, applyPxDefaults, applyTreeDeltas, arc, aspectRatio, attachFollow, attachSpring, attrEffect, axisDeltaEquals, axisEquals, axisEqualsRounded, boxEquals, boxEqualsRounded, buildHTMLStyles, buildProjectionTransform, buildSVGAttrs, buildSVGPath, buildTransform, calcAxisDelta, calcBoxDelta, calcChildStagger, calcGeneratorDuration, calcLength, calcRelativeAxis, calcRelativeAxisPosition, calcRelativeBox, calcRelativePosition, camelCaseAttributes, camelToDash, cancelFrame, cancelMicrotask, cancelSync, checkVariantsDidChange, cleanDirtyNodes, collectMotionValues, color, compareByDepth, complex, containsCSSVariable, convertBoundingBoxToBox, convertBoxToBoundingBox, convertOffsetToTimes, copyAxisDeltaInto, copyAxisInto, copyBoxInto, correctBorderRadius, correctBoxShadow, createAnimationState, createAxis, createAxisDelta, createBox, createDelta, createEffect, createGeneratorEasing, createProjectionNode, createRenderBatcher, cubicBezierAsString, defaultEasing, defaultOffset, defaultTransformValue, defaultValueTypes, degrees, delay, delayInSeconds, dimensionValueTypes, eachAxis, fillOffset, fillWildcards, findDimensionValueType, findEffect, findValueType, flushKeyframeResolvers, followValue, frame, frameData, frameSteps, generateLinearEasing, getAnimatableNone, getAnimationMap, getComputedStyle, getDefaultTransition, getDefaultValueType, getFeatureDefinitions, getFinalKeyframe, getMixer, getOptimisedAppearId, getOriginIndex, getValueAsType, getValueTransition, getVariableValue, getVariantContext, getViewAnimationLayerInfo, getViewAnimations, globalProjectionState, handOffElementState, has2DTranslate, hasComplexValues, hasReducedMotionListener, hasScale, hasTransform, hex, hover, hsla, hslaToRgba, inertia, initPrefersReducedMotion, interpolate, invisibleValues, isAnimationControls, isCSSVariableName, isCSSVariableToken, isControllingVariants, isDeltaZero, isDragActive, isDragging, isElementKeyboardAccessible, isElementTextInput, isForcedMotionValue, isGenerator, isHTMLElement, isKeyframesTarget, isMotionValue, isNear, isNodeOrChild, isPrimaryPointer, isSVGElement, isSVGSVGElement, isSVGTag, isTransitionDefined, isVariantLabel, isVariantNode, isWaapiSupportedEasing, isWillChangeMotionValue, keyframes, makeAnimationInstant, mapEasingToNativeEasing, mapValue, maxGeneratorDuration, measurePageBox, measureViewportBox, microtask, mix, mixArray, mixColor, mixComplex, mixImmediate, mixLinearColor, mixNumber, mixObject, mixValues, mixVisibility, motionValue, nodeGroup, number, numberValueTypes, optimizedAppearDataAttribute, optimizedAppearDataId, originProps, parseAnimateLayoutArgs, parseCSSVariable, parseValueFromTransform, percent, pixelsToPercent, positionalKeys, prefersReducedMotion, press, progressPercentage, propEffect, propagateDirtyNodes, px, readSVGValue, readStyleValue, readTransformValue, recordStats, removeAxisDelta, removeAxisTransforms, removeBoxTransforms, removeEffect, removePointDelta, renderHTML, renderSVG, resize, resolveElements, resolveMotionValue, resolveTransition, resolveVariant, resolveVariantFromProps, rgbUnit, rgba, rootProjectionNode, scale, scaleCorrectors, scalePoint, scrapeMotionValuesFromProps$1 as scrapeHTMLMotionValuesFromProps, scrapeMotionValuesFromProps as scrapeSVGMotionValuesFromProps, setDragLock, setFeatureDefinitions, setStyle, setTarget, spring, springValue, stagger, startWaapiAnimation, statsBuffer, styleEffect, styleSubjectEffect, supportedWaapiEasing, supportsBrowserAnimation, supportsFlags, supportsLinearEasing, supportsPartialKeyframes, supportsScrollTimeline, supportsViewTimeline, svgEffect, svgSubjectEffect, sync, testValueType, time, transform, transformAxis, transformBox, transformBoxPoints, transformPropOrder, transformProps, transformValue, transformValueTypes, translateAxis, updateMotionValuesFromProps, variantPriorityOrder, variantProps, vh, visualElementStore, vw };
|
package/dist/motion-dom.dev.js
CHANGED
|
@@ -1489,6 +1489,19 @@
|
|
|
1489
1489
|
}
|
|
1490
1490
|
}
|
|
1491
1491
|
|
|
1492
|
+
/**
|
|
1493
|
+
* If an animation's keyframes resolve, or its first frame renders, more than
|
|
1494
|
+
* this long after its start time, it starts from then instead. While we prefer
|
|
1495
|
+
* to "start" an animation as soon as it's triggered, this avoids a visual jump
|
|
1496
|
+
* into it after main thread work.
|
|
1497
|
+
*
|
|
1498
|
+
* Manual timing steps frames by however long it likes, so never lags.
|
|
1499
|
+
*/
|
|
1500
|
+
const MAX_START_DELAY = 40;
|
|
1501
|
+
const resolveStartTime = (startTime, now) => now - startTime > MAX_START_DELAY && !motionUtils.MotionGlobalConfig.useManualTiming
|
|
1502
|
+
? now
|
|
1503
|
+
: startTime;
|
|
1504
|
+
|
|
1492
1505
|
function baseRecord(kind, animation) {
|
|
1493
1506
|
return {
|
|
1494
1507
|
kind,
|
|
@@ -1684,6 +1697,10 @@
|
|
|
1684
1697
|
if (this.startTime === null)
|
|
1685
1698
|
return generator.next(0);
|
|
1686
1699
|
const { delay = 0, keyframes, repeat, repeatType, repeatDelay, type, onUpdate, finalKeyframe, } = this.options;
|
|
1700
|
+
if (this.startTime === this.pendingStartTime) {
|
|
1701
|
+
this.startTime = resolveStartTime(this.startTime, timestamp);
|
|
1702
|
+
}
|
|
1703
|
+
this.pendingStartTime = undefined;
|
|
1687
1704
|
/**
|
|
1688
1705
|
* requestAnimationFrame timestamps can come through as lower than
|
|
1689
1706
|
* the startTime as set by performance.now(). Here we prevent this,
|
|
@@ -1868,10 +1885,10 @@
|
|
|
1868
1885
|
this.startTime = now;
|
|
1869
1886
|
}
|
|
1870
1887
|
else if (this.holdTime !== null) {
|
|
1871
|
-
this.startTime = now - this.holdTime;
|
|
1888
|
+
this.startTime = now - this.holdTime / (this.playbackSpeed || 1);
|
|
1872
1889
|
}
|
|
1873
1890
|
else if (!this.startTime) {
|
|
1874
|
-
this.startTime = startTime ?? now;
|
|
1891
|
+
this.startTime = startTime ?? (this.pendingStartTime = now);
|
|
1875
1892
|
}
|
|
1876
1893
|
if (this.state === "finished" && this.speed < 0) {
|
|
1877
1894
|
this.startTime += this.calculatedDuration;
|
|
@@ -2991,15 +3008,6 @@
|
|
|
2991
3008
|
type !== "inertia");
|
|
2992
3009
|
}
|
|
2993
3010
|
|
|
2994
|
-
/**
|
|
2995
|
-
* Maximum time allowed between an animation being created and it being
|
|
2996
|
-
* resolved for us to use the latter as the start time.
|
|
2997
|
-
*
|
|
2998
|
-
* This is to ensure that while we prefer to "start" an animation as soon
|
|
2999
|
-
* as it's triggered, we also want to avoid a visual jump if there's a big delay
|
|
3000
|
-
* between these two moments.
|
|
3001
|
-
*/
|
|
3002
|
-
const MAX_RESOLVE_DELAY = 40;
|
|
3003
3011
|
class AsyncMotionValueAnimation extends WithPromise {
|
|
3004
3012
|
constructor(options) {
|
|
3005
3013
|
super();
|
|
@@ -3048,31 +3056,7 @@
|
|
|
3048
3056
|
makeAnimationInstant(options);
|
|
3049
3057
|
options.repeat = 0;
|
|
3050
3058
|
}
|
|
3051
|
-
/**
|
|
3052
|
-
* Resolve startTime for the animation.
|
|
3053
|
-
*
|
|
3054
|
-
* This method uses the createdAt and resolvedAt to calculate the
|
|
3055
|
-
* animation startTime. *Ideally*, we would use the createdAt time as t=0
|
|
3056
|
-
* as the following frame would then be the first frame of the animation in
|
|
3057
|
-
* progress, which would feel snappier.
|
|
3058
|
-
*
|
|
3059
|
-
* However, if there's a delay (main thread work) between the creation of
|
|
3060
|
-
* the animation and the first committed frame, we prefer to use resolvedAt
|
|
3061
|
-
* to avoid a sudden jump into the animation.
|
|
3062
|
-
*/
|
|
3063
|
-
const startTime = sync
|
|
3064
|
-
? !this.resolvedAt
|
|
3065
|
-
? this.createdAt
|
|
3066
|
-
: this.resolvedAt - this.createdAt > MAX_RESOLVE_DELAY
|
|
3067
|
-
? this.resolvedAt
|
|
3068
|
-
: this.createdAt
|
|
3069
|
-
: undefined;
|
|
3070
3059
|
const { onComplete } = options;
|
|
3071
|
-
/**
|
|
3072
|
-
* A startTime passed in options (an optimised appear handoff syncing
|
|
3073
|
-
* to its WAAPI animation) takes precedence over the derived one.
|
|
3074
|
-
*/
|
|
3075
|
-
options.startTime ?? (options.startTime = startTime);
|
|
3076
3060
|
options.finalKeyframe = finalKeyframe;
|
|
3077
3061
|
options.keyframes = keyframes;
|
|
3078
3062
|
/**
|
|
@@ -3093,6 +3077,24 @@
|
|
|
3093
3077
|
* values may not be valid CSS and would trigger browser warnings.
|
|
3094
3078
|
*/
|
|
3095
3079
|
const useWaapi = canAnimateValue && !isHandoff && supportsBrowserAnimation(options);
|
|
3080
|
+
/**
|
|
3081
|
+
* Resolve startTime for the animation. A startTime passed in options
|
|
3082
|
+
* (an optimised appear handoff syncing to its WAAPI animation) takes
|
|
3083
|
+
* precedence.
|
|
3084
|
+
*
|
|
3085
|
+
* *Ideally*, we would use the createdAt time as t=0 as the following
|
|
3086
|
+
* frame would then be the first frame of the animation in progress,
|
|
3087
|
+
* which would feel snappier. If keyframes resolved on a later frame,
|
|
3088
|
+
* and long after creation, we start from then instead.
|
|
3089
|
+
*
|
|
3090
|
+
* If they resolved immediately, a JSAnimation picks its own start
|
|
3091
|
+
* time and resolves it the same way on its first frame, so every
|
|
3092
|
+
* animation started in that moment stays in sync. WAAPI has no frame
|
|
3093
|
+
* of ours to do that on.
|
|
3094
|
+
*/
|
|
3095
|
+
if (sync && (useWaapi || this.resolvedAt !== this.createdAt)) {
|
|
3096
|
+
options.startTime ?? (options.startTime = resolveStartTime(this.createdAt, this.resolvedAt));
|
|
3097
|
+
}
|
|
3096
3098
|
let animation;
|
|
3097
3099
|
if (useWaapi) {
|
|
3098
3100
|
/**
|
|
@@ -5192,9 +5194,16 @@
|
|
|
5192
5194
|
attrs[keys.array] = `${length} ${spacing}`;
|
|
5193
5195
|
}
|
|
5194
5196
|
|
|
5197
|
+
/**
|
|
5198
|
+
* Values rendered via style rather than as attributes. This must include
|
|
5199
|
+
* every value WAAPI can accelerate, as WAAPI writes its final value to
|
|
5200
|
+
* style, which would otherwise override later attribute writes.
|
|
5201
|
+
*/
|
|
5195
5202
|
const cssStyleProperties = [
|
|
5196
5203
|
"transform",
|
|
5197
5204
|
"opacity",
|
|
5205
|
+
"clipPath",
|
|
5206
|
+
"filter",
|
|
5198
5207
|
"offsetDistance",
|
|
5199
5208
|
"offsetPath",
|
|
5200
5209
|
"offsetRotate",
|
|
@@ -6208,6 +6217,10 @@
|
|
|
6208
6217
|
tick(timestamp) {
|
|
6209
6218
|
const { options, hasNextTarget: retargeted } = this;
|
|
6210
6219
|
const { delay = 0, onUpdate, onPlay } = options;
|
|
6220
|
+
// Retargets happen on a tick, so only the first start can lag
|
|
6221
|
+
if (!this.started) {
|
|
6222
|
+
this.startTime = resolveStartTime(this.startTime, timestamp);
|
|
6223
|
+
}
|
|
6211
6224
|
const elapsed = Math.round(timestamp - this.startTime) - delay;
|
|
6212
6225
|
const t = (this.currentTime = Math.max(0, elapsed));
|
|
6213
6226
|
const state = this.generator.next(t);
|
|
@@ -8764,6 +8777,20 @@
|
|
|
8764
8777
|
: visualElement.initialValues[key] === undefined
|
|
8765
8778
|
? visualElement.baseTarget[key]
|
|
8766
8779
|
: undefined) ?? null;
|
|
8780
|
+
/**
|
|
8781
|
+
* If it stays where it is, that's now its base. Otherwise a
|
|
8782
|
+
* later removal (like a gesture ending) would also stay,
|
|
8783
|
+
* leaving the value stuck. Stop first so accelerated
|
|
8784
|
+
* animations sync the value they reached. In practice initial
|
|
8785
|
+
* only changes like this with Fast Refresh, so this is
|
|
8786
|
+
* dev-only (#3787).
|
|
8787
|
+
*/
|
|
8788
|
+
if (fallbackAnimation[key] === null &&
|
|
8789
|
+
visualElement.initialValues[key] !== undefined) {
|
|
8790
|
+
delete visualElement.initialValues[key];
|
|
8791
|
+
motionValue?.stop();
|
|
8792
|
+
visualElement.baseTarget[key] = motionValue?.get();
|
|
8793
|
+
}
|
|
8767
8794
|
});
|
|
8768
8795
|
animations.push({ animation: fallbackAnimation });
|
|
8769
8796
|
}
|
|
@@ -9635,7 +9662,7 @@
|
|
|
9635
9662
|
visualElement &&
|
|
9636
9663
|
(layoutId || layout)) {
|
|
9637
9664
|
this.addEventListener("didUpdate", ({ delta, hasLayoutChanged, hasRelativeLayoutChanged, layout: newLayout, }) => {
|
|
9638
|
-
if (this.
|
|
9665
|
+
if (this.isAnimationBlocked) {
|
|
9639
9666
|
this.target = undefined;
|
|
9640
9667
|
this.relativeTarget = undefined;
|
|
9641
9668
|
return;
|
|
@@ -9727,11 +9754,6 @@
|
|
|
9727
9754
|
isUpdateBlocked() {
|
|
9728
9755
|
return this.updateManuallyBlocked || this.updateBlockedByResize;
|
|
9729
9756
|
}
|
|
9730
|
-
isTreeAnimationBlocked() {
|
|
9731
|
-
return (this.isAnimationBlocked ||
|
|
9732
|
-
(this.parent && this.parent.isTreeAnimationBlocked()) ||
|
|
9733
|
-
false);
|
|
9734
|
-
}
|
|
9735
9757
|
// Note: currently only running on root node
|
|
9736
9758
|
startUpdate() {
|
|
9737
9759
|
if (this.isUpdateBlocked())
|
|
@@ -9785,6 +9807,14 @@
|
|
|
9785
9807
|
if (node.options.layoutRoot) {
|
|
9786
9808
|
node.willUpdate(false);
|
|
9787
9809
|
}
|
|
9810
|
+
/**
|
|
9811
|
+
* Measure the nearest dragged ancestor before the DOM
|
|
9812
|
+
* changes, so this node can follow its layout change.
|
|
9813
|
+
*/
|
|
9814
|
+
if (node.isAnimationBlocked) {
|
|
9815
|
+
node.dragSnapshot || (node.dragSnapshot = node.measure());
|
|
9816
|
+
this.dragAncestor = node;
|
|
9817
|
+
}
|
|
9788
9818
|
}
|
|
9789
9819
|
const { layoutId, layout } = this.options;
|
|
9790
9820
|
if (layoutId === undefined && !layout)
|
|
@@ -10792,7 +10822,11 @@
|
|
|
10792
10822
|
}
|
|
10793
10823
|
}
|
|
10794
10824
|
clearSnapshot() {
|
|
10795
|
-
this.resumeFrom =
|
|
10825
|
+
this.resumeFrom =
|
|
10826
|
+
this.snapshot =
|
|
10827
|
+
this.dragSnapshot =
|
|
10828
|
+
this.dragAncestor =
|
|
10829
|
+
undefined;
|
|
10796
10830
|
}
|
|
10797
10831
|
// Only run on root
|
|
10798
10832
|
resetTree() {
|
|
@@ -10802,8 +10836,13 @@
|
|
|
10802
10836
|
}
|
|
10803
10837
|
};
|
|
10804
10838
|
}
|
|
10839
|
+
/**
|
|
10840
|
+
* Nodes are depth-ordered, so a dragged ancestor's layout is updated before
|
|
10841
|
+
* its descendants'.
|
|
10842
|
+
*/
|
|
10805
10843
|
function updateLayout(node) {
|
|
10806
10844
|
node.updateLayout();
|
|
10845
|
+
followDraggedAncestor(node);
|
|
10807
10846
|
}
|
|
10808
10847
|
function notifyLayoutUpdate(node) {
|
|
10809
10848
|
const snapshot = node.resumeFrom?.snapshot || node.snapshot;
|
|
@@ -10952,6 +10991,19 @@
|
|
|
10952
10991
|
function clearIsLayoutDirty(node) {
|
|
10953
10992
|
node.isLayoutDirty = false;
|
|
10954
10993
|
}
|
|
10994
|
+
/**
|
|
10995
|
+
* A dragged node doesn't layout animate, so it jumps to its new layout. Shift
|
|
10996
|
+
* its descendants' snapshots by the same amount, so they only animate layout
|
|
10997
|
+
* changes relative to it, rather than lagging behind.
|
|
10998
|
+
*/
|
|
10999
|
+
function followDraggedAncestor(node) {
|
|
11000
|
+
const { snapshot, dragAncestor } = node;
|
|
11001
|
+
const to = dragAncestor?.layout;
|
|
11002
|
+
if (!snapshot || !to || node.resumeFrom || node.isAnimationBlocked)
|
|
11003
|
+
return;
|
|
11004
|
+
const from = dragAncestor.dragSnapshot;
|
|
11005
|
+
eachAxis((axis) => translateAxis(snapshot.layoutBox[axis], to.layoutBox[axis].min - from.layoutBox[axis].min));
|
|
11006
|
+
}
|
|
10955
11007
|
/**
|
|
10956
11008
|
* When a node is animation-blocked (e.g. during drag) and its component
|
|
10957
11009
|
* didn't re-render (memoized), willUpdate() is never called so there's
|
|
@@ -10960,7 +11012,7 @@
|
|
|
10960
11012
|
*/
|
|
10961
11013
|
function ensureDraggedNodesSnapshotted(node) {
|
|
10962
11014
|
if (node.isAnimationBlocked && node.layout && !node.isLayoutDirty) {
|
|
10963
|
-
node.snapshot = node.layout;
|
|
11015
|
+
node.snapshot = node.dragSnapshot || node.layout;
|
|
10964
11016
|
node.isLayoutDirty = true;
|
|
10965
11017
|
}
|
|
10966
11018
|
}
|
|
@@ -11461,6 +11513,21 @@
|
|
|
11461
11513
|
};
|
|
11462
11514
|
}
|
|
11463
11515
|
|
|
11516
|
+
/**
|
|
11517
|
+
* Animate layout changes made within `updateDom` on elements tagged
|
|
11518
|
+
* with `data-layout` or `data-layout-id`.
|
|
11519
|
+
*
|
|
11520
|
+
* ```
|
|
11521
|
+
* animateLayout(() => {
|
|
11522
|
+
* element.style.justifyContent = "flex-end"
|
|
11523
|
+
* })
|
|
11524
|
+
* ```
|
|
11525
|
+
*/
|
|
11526
|
+
function animateLayout(scopeOrUpdateDom, updateDomOrOptions, options) {
|
|
11527
|
+
const { scope, updateDom, defaultOptions } = parseAnimateLayoutArgs(scopeOrUpdateDom, updateDomOrOptions, options);
|
|
11528
|
+
return new LayoutAnimationBuilder(scope, updateDom, defaultOptions);
|
|
11529
|
+
}
|
|
11530
|
+
|
|
11464
11531
|
/**
|
|
11465
11532
|
* @deprecated
|
|
11466
11533
|
*
|
|
@@ -11512,6 +11579,7 @@
|
|
|
11512
11579
|
exports.analyseComplexValue = analyseComplexValue;
|
|
11513
11580
|
exports.animateEffectSubject = animateEffectSubject;
|
|
11514
11581
|
exports.animateElement = animateElement;
|
|
11582
|
+
exports.animateLayout = animateLayout;
|
|
11515
11583
|
exports.animateMotionValue = animateMotionValue;
|
|
11516
11584
|
exports.animateSingleValue = animateSingleValue;
|
|
11517
11585
|
exports.animateTarget = animateTarget;
|