motion-dom 12.40.0 → 12.41.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 +1023 -458
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/JSAnimation.mjs +0 -3
- package/dist/es/animation/JSAnimation.mjs.map +1 -1
- package/dist/es/animation/waapi/start-waapi-animation.mjs +1 -12
- package/dist/es/animation/waapi/start-waapi-animation.mjs.map +1 -1
- package/dist/es/events/add-dom-event.mjs +1 -1
- package/dist/es/events/add-dom-event.mjs.map +1 -1
- package/dist/es/frameloop/batcher.mjs +1 -1
- package/dist/es/frameloop/batcher.mjs.map +1 -1
- package/dist/es/frameloop/render-step.mjs +1 -12
- package/dist/es/frameloop/render-step.mjs.map +1 -1
- package/dist/es/gestures/press/index.mjs +11 -4
- package/dist/es/gestures/press/index.mjs.map +1 -1
- package/dist/es/index.mjs +0 -1
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/layout/LayoutAnimationBuilder.mjs +299 -214
- package/dist/es/layout/LayoutAnimationBuilder.mjs.map +1 -1
- package/dist/es/projection/node/create-projection-node.mjs +0 -6
- package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
- package/dist/es/stats/buffer.mjs.map +1 -1
- package/dist/es/stats/index.mjs +4 -93
- package/dist/es/stats/index.mjs.map +1 -1
- package/dist/es/view/index.mjs +90 -13
- package/dist/es/view/index.mjs.map +1 -1
- package/dist/es/view/queue.mjs +9 -3
- package/dist/es/view/queue.mjs.map +1 -1
- package/dist/es/view/start.mjs +484 -83
- package/dist/es/view/start.mjs.map +1 -1
- package/dist/es/view/utils/assign-names.mjs +118 -0
- package/dist/es/view/utils/assign-names.mjs.map +1 -0
- package/dist/es/view/utils/choose-layer-type.mjs +1 -3
- package/dist/es/view/utils/choose-layer-type.mjs.map +1 -1
- package/dist/es/view/utils/get-layer-info.mjs +3 -1
- package/dist/es/view/utils/get-layer-info.mjs.map +1 -1
- package/dist/es/view/utils/get-view-animations.mjs +6 -8
- package/dist/es/view/utils/get-view-animations.mjs.map +1 -1
- package/dist/index.d.ts +105 -52
- package/dist/motion-dom.dev.js +1023 -458
- package/dist/motion-dom.js +1 -1
- package/dist/size-rollup-motion-value.js.map +1 -1
- package/dist/size-rollup-style-effect.js.map +1 -1
- package/package.json +2 -2
- package/dist/es/stats/animation-count.mjs +0 -8
- package/dist/es/stats/animation-count.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.mjs","sources":["../../../src/view/start.ts"],"sourcesContent":["import { secondsToMilliseconds } from \"motion-utils\"\nimport { GroupAnimation } from \"../animation/GroupAnimation\"\nimport { NativeAnimation } from \"../animation/NativeAnimation\"\nimport { NativeAnimationWrapper } from \"../animation/NativeAnimationWrapper\"\nimport { AnimationPlaybackControls } from \"../animation/types\"\nimport { getValueTransition } from \"../animation/utils/get-value-transition\"\nimport { mapEasingToNativeEasing } from \"../animation/waapi/easing/map-easing\"\nimport { applyGeneratorOptions } from \"../animation/waapi/utils/apply-generator\"\nimport type { ViewTransitionBuilder } from \"./index\"\nimport { ViewTransitionTarget } from \"./types\"\nimport { chooseLayerType } from \"./utils/choose-layer-type\"\nimport { css } from \"./utils/css\"\nimport { getViewAnimationLayerInfo } from \"./utils/get-layer-info\"\nimport { getViewAnimations } from \"./utils/get-view-animations\"\nimport { hasTarget } from \"./utils/has-target\"\n\nconst definitionNames = [\"layout\", \"enter\", \"exit\", \"new\", \"old\"] as const\n\nexport function startViewAnimation(\n builder: ViewTransitionBuilder\n): Promise<GroupAnimation> {\n const { update, targets, options: defaultOptions } = builder\n\n if (!document.startViewTransition) {\n return new Promise(async (resolve) => {\n await update()\n resolve(new GroupAnimation([]))\n })\n }\n\n // TODO: Go over existing targets and ensure they all have ids\n\n /**\n * If we don't have any animations defined for the root target,\n * remove it from being captured.\n */\n if (!hasTarget(\"root\", targets)) {\n css.set(\":root\", {\n \"view-transition-name\": \"none\",\n })\n }\n\n /**\n * Set the timing curve to linear for all view transition layers.\n * This gets baked into the keyframes, which can't be changed\n * without breaking the generated animation.\n *\n * This allows us to set easing via updateTiming - which can be changed.\n */\n css.set(\n \"::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*)\",\n { \"animation-timing-function\": \"linear !important\" }\n )\n\n css.commit() // Write\n\n const transition = document.startViewTransition(async () => {\n await update()\n\n // TODO: Go over new targets and ensure they all have ids\n })\n\n transition.finished.finally(() => {\n css.remove() // Write\n })\n\n return new Promise((resolve) => {\n transition.ready.then(() => {\n const generatedViewAnimations = getViewAnimations()\n\n const animations: AnimationPlaybackControls[] = []\n\n /**\n * Create animations for each of our explicitly-defined subjects.\n */\n targets.forEach((definition, target) => {\n // TODO: If target is not \"root\", resolve elements\n // and iterate over each\n for (const key of definitionNames) {\n if (!definition[key]) continue\n const { keyframes, options } =\n definition[key as keyof ViewTransitionTarget]!\n\n for (let [valueName, valueKeyframes] of Object.entries(\n keyframes\n )) {\n if (!valueKeyframes) continue\n\n const valueOptions = {\n ...getValueTransition(\n defaultOptions as any,\n valueName\n ),\n ...getValueTransition(options as any, valueName),\n }\n\n const type = chooseLayerType(\n key as keyof ViewTransitionTarget\n )\n\n /**\n * If this is an opacity animation, and keyframes are not an array,\n * we need to convert them into an array and set an initial value.\n */\n if (\n valueName === \"opacity\" &&\n !Array.isArray(valueKeyframes)\n ) {\n const initialValue = type === \"new\" ? 0 : 1\n valueKeyframes = [initialValue, valueKeyframes]\n }\n\n /**\n * Resolve stagger function if provided.\n */\n if (typeof valueOptions.delay === \"function\") {\n valueOptions.delay = valueOptions.delay(0, 1)\n }\n\n valueOptions.duration &&= secondsToMilliseconds(\n valueOptions.duration\n )\n\n valueOptions.delay &&= secondsToMilliseconds(\n valueOptions.delay\n )\n\n const animation = new NativeAnimation({\n ...valueOptions,\n element: document.documentElement,\n name: valueName,\n pseudoElement: `::view-transition-${type}(${target})`,\n keyframes: valueKeyframes,\n })\n\n animations.push(animation)\n }\n }\n })\n\n /**\n * Handle browser generated animations\n */\n for (const animation of generatedViewAnimations) {\n if (animation.playState === \"finished\") continue\n\n const { effect } = animation\n if (!effect || !(effect instanceof KeyframeEffect)) continue\n\n const { pseudoElement } = effect\n if (!pseudoElement) continue\n\n const name = getViewAnimationLayerInfo(pseudoElement)\n if (!name) continue\n\n const targetDefinition = targets.get(name.layer)\n\n if (!targetDefinition) {\n /**\n * If transition name is group then update the timing of the animation\n * whereas if it's old or new then we could possibly replace it using\n * the above method.\n */\n const transitionName = name.type === \"group\" ? \"layout\" : \"\"\n let animationTransition = {\n ...getValueTransition(defaultOptions, transitionName),\n }\n\n animationTransition.duration &&= secondsToMilliseconds(\n animationTransition.duration\n )\n\n animationTransition =\n applyGeneratorOptions(animationTransition)\n\n const easing = mapEasingToNativeEasing(\n animationTransition.ease,\n animationTransition.duration!\n ) as string\n\n effect.updateTiming({\n delay: secondsToMilliseconds(\n animationTransition.delay ?? 0\n ),\n duration: animationTransition.duration,\n easing,\n })\n\n animations.push(new NativeAnimationWrapper(animation))\n } else if (\n hasOpacity(targetDefinition, \"enter\") &&\n hasOpacity(targetDefinition, \"exit\") &&\n effect\n .getKeyframes()\n .some((keyframe) => keyframe.mixBlendMode)\n ) {\n animations.push(new NativeAnimationWrapper(animation))\n } else {\n animation.cancel()\n }\n }\n\n resolve(new GroupAnimation(animations))\n })\n })\n}\n\nfunction hasOpacity(\n target: ViewTransitionTarget | undefined,\n key: \"enter\" | \"exit\" | \"layout\"\n) {\n return target?.[key]?.keyframes.opacity\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAgBA,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAU;AAEpE,SAAU,kBAAkB,CAC9B,OAA8B,EAAA;IAE9B,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,OAAO;AAE5D,IAAA,IAAI,CAAC,QAAQ,CAAC,mBAA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C;oBAEF,UAAU,CAAC,IAAI,CAAC,IAAI,sBAAsB,CAAC,SAAS,CAAC,CAAC;gBAC1D;AAAO,qBAAA,IACH,UAAU,CAAC,gBAAgB,EAAE,OAAO,CAAC;AACrC,oBAAA,UAAU,CAAC,gBAAgB,EAAE,MAAM,CAAC;oBACpC;AACK,yBAAA,YAAY;yBACZ,IAAI,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,YAAY,CAAC,EAChD;oBACE,UAAU,CAAC,IAAI,CAAC,IAAI,sBAAsB,CAAC,SAAS,CAAC,CAAC;gBAC1D;qBAAO;oBACH,SAAS,CAAC,MAAM,EAAE;gBACtB;YACJ;AAEA,YAAA,OAAO,CAAC,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;AAC3C,QAAA,CAAC,CAAC;AACN,IAAA,CAAC,CAAC;AACN;AAEA,SAAS,UAAU,CACf,MAAwC,EACxC,GAAgC,EAAA;IAEhC,OAAO,MAAM,GAAG,GAAG,CAAC,EAAE,SAAS,CAAC,OAAO;AAC3C;;;;"}
|
|
1
|
+
{"version":3,"file":"start.mjs","sources":["../../../src/view/start.ts"],"sourcesContent":["import { secondsToMilliseconds, warnOnce } from \"motion-utils\"\nimport { GroupAnimation } from \"../animation/GroupAnimation\"\nimport { NativeAnimation } from \"../animation/NativeAnimation\"\nimport { NativeAnimationWrapper } from \"../animation/NativeAnimationWrapper\"\nimport { AnimationPlaybackControls, DOMKeyframesDefinition } from \"../animation/types\"\nimport { getValueTransition } from \"../animation/utils/get-value-transition\"\nimport { mapEasingToNativeEasing } from \"../animation/waapi/easing/map-easing\"\nimport { applyGeneratorOptions } from \"../animation/waapi/utils/apply-generator\"\nimport { ElementOrSelector, resolveElements } from \"../utils/resolve-elements\"\nimport type { ViewTransitionBuilder } from \"./index\"\nimport { ViewTransitionTarget, ViewTransitionTargetDefinition } from \"./types\"\nimport {\n assignViewTransitionNames,\n releaseViewTransitionNames,\n} from \"./utils/assign-names\"\nimport { chooseLayerType } from \"./utils/choose-layer-type\"\nimport { css } from \"./utils/css\"\nimport { getViewAnimationLayerInfo } from \"./utils/get-layer-info\"\nimport { getViewAnimations } from \"./utils/get-view-animations\"\nimport { hasTarget } from \"./utils/has-target\"\n\nconst definitionNames = [\"layout\", \"enter\", \"exit\", \"new\", \"old\"] as const\n\n/**\n * The `ViewTransitionTarget` buckets driving each generated layer type, in\n * priority order - the inverse of `chooseLayerType`. The new view is driven by\n * `new`/`enter`, the old by `old`/`exit`. `group-children`/`image-pair` have no\n * bucket; they follow the default layout timing.\n */\nconst typeBuckets: Record<string, (keyof ViewTransitionTarget)[]> = {\n group: [\"layout\"],\n new: [\"new\", \"enter\"],\n old: [\"old\", \"exit\"],\n}\n\n/**\n * Default \"absent\" origin for a single-value keyframe, by pseudo type, so e.g.\n * `enter({ scale: 1 })` grows in from 0.85 and `exit({ opacity: 0 })` fades\n * from 1. `enter` prefers the matching `exit` value over these (see below).\n */\nconst ORIGIN_DEFAULTS: Record<string, Record<string, number>> = {\n new: { opacity: 0, scale: 0.85 },\n old: { opacity: 1, scale: 1 },\n}\n\nconst cornerProps = [\n \"borderTopLeftRadius\",\n \"borderTopRightRadius\",\n \"borderBottomRightRadius\",\n \"borderBottomLeftRadius\",\n] as const\n\ntype CornerRadii = Record<(typeof cornerProps)[number], string>\n\nexport function startViewAnimation(\n builder: ViewTransitionBuilder\n): Promise<GroupAnimation> {\n const {\n update,\n targets,\n resolveDefs,\n noCrop,\n pairs,\n classNames,\n options: defaultOptions,\n } = builder\n\n if (!document.startViewTransition) {\n // An async IIFE (not `new Promise(async …)`) so a throwing/rejecting\n // update rejects this promise rather than leaving it unsettled.\n return (async () => {\n await update()\n return new GroupAnimation([])\n })()\n }\n\n /**\n * Resolve any selector/Element targets to layer names, assigning a\n * `view-transition-name` to each element as we go. We run this before the\n * update (so the elements are captured in the old snapshot) and again\n * after it (for the new snapshot). An element present in both keeps the\n * same name and animates as a single `group` layer.\n */\n const nameRegistry = new Map<Element, string>()\n const assigned: Element[] = []\n /**\n * Elements we tagged with a `view-transition-class` (via `.class()`),\n * tracked separately from `assigned` so cleanup removes the class without\n * ever stripping an author's own inline `view-transition-name`.\n */\n const classed: Element[] = []\n const layerTargets = new Map<string, ViewTransitionTarget>()\n const croppedNames = new Set<string>()\n /**\n * Each layer's stagger position (index + total) within its subject, per\n * snapshot. Resolving against the snapshot the layer belongs to keeps\n * stagger correct when `update()` replaces the matched elements, and lets\n * us skip a layer that's absent from a snapshot (e.g. an exited element\n * has no `new` pseudo-element).\n */\n const layerStagger = new Map<\n string,\n { old?: [number, number]; new?: [number, number] }\n >()\n /**\n * Names allocated for a paired subject in the old snapshot, replayed onto\n * its new-snapshot target so both ends share a layer and morph.\n */\n const pairNames = new Map<ViewTransitionTargetDefinition, string[]>()\n /**\n * The old (`from`) elements of each paired subject, so their names can be\n * transferred off before the new (`to`) elements inherit them.\n */\n const pairFrom = new Map<ViewTransitionTargetDefinition, Element[]>()\n\n const resolveLayers = (phase: \"old\" | \"new\") => {\n targets.forEach((target, definition) => {\n const className = classNames.get(definition)\n let names: string[]\n if (definition === \"root\" || !resolveDefs.has(definition)) {\n names = [definition as string]\n } else if (pairs.has(definition)) {\n /**\n * Paired morph: name the old target in the old snapshot, then\n * force the same name(s) onto the new target in the new one, so\n * two different elements morph as a single layer.\n */\n if (phase === \"old\") {\n pairFrom.set(\n definition,\n resolveElements(definition as ElementOrSelector)\n )\n names = assignViewTransitionNames(\n definition as ElementOrSelector,\n nameRegistry,\n assigned,\n undefined,\n className,\n classed\n )\n pairNames.set(definition, names)\n } else {\n /**\n * Transfer the name(s) off the `from` elements before the\n * `to` elements inherit them. A `from` that survives into\n * the new snapshot (e.g. hidden with `visibility: hidden`\n * rather than removed) would otherwise keep the name and\n * collide - \"duplicate view-transition-name\".\n */\n for (const el of pairFrom.get(definition) ?? []) {\n ;(el as HTMLElement).style?.removeProperty(\n \"view-transition-name\"\n )\n /**\n * Drop the old end from the registry too, so the new\n * end alone supplies this name's `new` crop radii - we\n * neither re-measure nor get ordered by a stale element.\n */\n nameRegistry.delete(el)\n }\n names = assignViewTransitionNames(\n pairs.get(definition) as ElementOrSelector,\n nameRegistry,\n assigned,\n pairNames.get(definition),\n className,\n classed\n )\n }\n } else {\n names = assignViewTransitionNames(\n definition as ElementOrSelector,\n nameRegistry,\n assigned,\n undefined,\n className,\n classed\n )\n }\n\n const cropped = definition !== \"root\" && !noCrop.has(definition)\n\n names.forEach((name, index) => {\n /**\n * If two subjects resolve to the same element, merge their\n * definitions so neither subject's animations are dropped.\n */\n const existing = layerTargets.get(name)\n layerTargets.set(\n name,\n existing && existing !== target\n ? { ...existing, ...target }\n : target\n )\n\n if (cropped) croppedNames.add(name)\n\n const stagger = layerStagger.get(name) ?? {}\n stagger[phase] = [index, names.length]\n layerStagger.set(name, stagger)\n })\n })\n }\n\n /**\n * The stagger index/total for a layer, resolved against the snapshot it\n * belongs to. Returns index -1 when the layer is absent from that snapshot\n * so the caller can skip a pseudo-element that doesn't exist.\n */\n const staggerPosition = (name: string, type: string) => {\n const stagger = layerStagger.get(name)\n const position =\n type === \"old\"\n ? stagger?.old\n : type === \"new\"\n ? stagger?.new\n : // group / group-children / image-pair persist across both.\n stagger?.new ?? stagger?.old\n return position ?? ([-1, 1] as const)\n }\n\n /**\n * Merge default + per-layer transition options for a generated layer and\n * resolve any stagger/delay function against this element's position. Used\n * by both the morph-retiming and crop corner-radius passes.\n */\n const resolveLayerTransition = (\n target: ViewTransitionTarget | undefined,\n type: string,\n transitionName: string,\n index: number,\n total: number\n ) => {\n const transition = mergeTransition(\n getValueTransition(defaultOptions, transitionName),\n getValueTransition(\n (layerOptions(target, type) ?? {}) as any,\n transitionName\n )\n )\n\n if (typeof transition.delay === \"function\") {\n transition.delay = transition.delay(index, total)\n }\n\n return transition\n }\n\n /**\n * Measured corner radii per cropped layer, so the clip can animate each\n * corner between the old and new elements. Per-corner (rather than the\n * shorthand) so mismatched/individual radii interpolate cleanly.\n */\n const cropRadii = new Map<string, { old?: CornerRadii; new?: CornerRadii }>()\n\n const recordRadii = (\n style: CSSStyleDeclaration,\n name: string,\n phase: \"old\" | \"new\"\n ) => {\n const corners = {} as CornerRadii\n for (const corner of cornerProps) corners[corner] = style[corner]\n\n const entry = cropRadii.get(name) ?? {}\n entry[phase] = corners\n cropRadii.set(name, entry)\n }\n\n /**\n * Cropped layers all come from `.add()`, so their elements are in the\n * registry - read each one's corner radii directly. For a paired morph both\n * ends share a name; the new-snapshot element is registered last, so it\n * wins the `new` reading (and the old end the `old` reading).\n */\n const measureCrop = (phase: \"old\" | \"new\") => {\n if (!croppedNames.size) return\n\n nameRegistry.forEach((name, element) => {\n if (croppedNames.has(name)) {\n recordRadii(getComputedStyle(element), name, phase)\n }\n })\n }\n\n /**\n * Write the persistent view-transition CSS: suppress root capture when the\n * root has no animations of its own; force linear timing (baked into the\n * keyframes, so we can retime later via updateTiming); and clip +\n * object-fit: cover every cropped morph (the UA default overflows on\n * aspect-ratio change), with an animated border-radius added below.\n *\n * `css.commit` replaces rather than appends, so we re-set the full rule set\n * each call - the second call (in the update callback) then picks up cropped\n * layers that only exist in the new snapshot.\n */\n const commitViewCSS = () => {\n if (!hasTarget(\"root\", targets)) {\n css.set(\":root\", { \"view-transition-name\": \"none\" })\n }\n\n css.set(\n \"::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*)\",\n { \"animation-timing-function\": \"linear !important\" }\n )\n\n croppedNames.forEach((name) => {\n css.set(`::view-transition-group(${name})`, { overflow: \"clip\" })\n css.set(\n `::view-transition-old(${name}), ::view-transition-new(${name})`,\n { width: \"100%\", height: \"100%\", \"object-fit\": \"cover\" }\n )\n })\n\n css.commit() // Write\n }\n\n const cleanup = () => {\n releaseViewTransitionNames(assigned, classed)\n css.remove() // Write\n }\n\n const callback = async () => {\n await update()\n\n /**\n * Re-resolve so elements created by the update are named for the new\n * snapshot, then measure the cropped layers' new border-radius.\n */\n const croppedBefore = croppedNames.size\n resolveLayers(\"new\")\n measureCrop(\"new\")\n\n /**\n * Re-commit the crop CSS only if the new snapshot introduced cropped\n * layers, so a layer that exists only in the new snapshot is clipped\n * too - without forcing a redundant style write on the common path.\n */\n if (croppedNames.size > croppedBefore) commitViewCSS()\n }\n\n let transition: ViewTransition\n try {\n resolveLayers(\"old\")\n measureCrop(\"old\")\n commitViewCSS()\n transition = document.startViewTransition(callback)\n } catch (error) {\n /**\n * The prelude writes inline names before the transition exists. If it\n * throws (e.g. startViewTransition rejects in a bad UA state), release\n * them so we neither leak DOM state nor stall the queue on a promise\n * that never settles - hand back a rejection it can advance past.\n */\n cleanup()\n return Promise.reject(error)\n }\n\n transition.finished.finally(cleanup)\n\n return new Promise<GroupAnimation>((resolve, reject) => {\n transition.ready\n .then(() => {\n const generatedViewAnimations = getViewAnimations()\n\n const animations: AnimationPlaybackControls[] = []\n\n /**\n * Create animations for each of our explicitly-defined subjects.\n * `opacityAnimated` additionally tracks which `${name}:${type}`\n * we faded, so we can keep the UA `plus-lighter` blend only for a\n * genuine opacity crossfade (both sides fading) and drop it for a\n * slide/transform, where additive compositing would flash bright.\n */\n const explicitlyAnimated = new Set<string>()\n const opacityAnimated = new Set<string>()\n layerTargets.forEach((target, name) => {\n const stagger = layerStagger.get(name)\n /**\n * Presence: `enter` only fires for a pure newcomer (a new\n * view with no old), `exit` only for a pure leaver. A\n * survivor (both) gets neither - it just morphs.\n */\n const enterApplies = !!stagger?.new && !stagger?.old\n const exitApplies = !!stagger?.old && !stagger?.new\n\n for (const key of definitionNames) {\n if (!target[key]) continue\n if (key === \"enter\" && !enterApplies) continue\n if (key === \"exit\" && !exitApplies) continue\n\n const type = chooseLayerType(\n key as keyof ViewTransitionTarget\n )\n const [index, total] = staggerPosition(name, type)\n // Skip a layer absent from its snapshot.\n if (index === -1) continue\n\n const { keyframes, options } =\n target[key as keyof ViewTransitionTarget]!\n\n for (let [valueName, valueKeyframes] of Object.entries(\n keyframes\n )) {\n // Skip only missing values - `0` (e.g. opacity: 0)\n // is valid and must reach the from-value inference.\n if (valueKeyframes == null) continue\n\n /**\n * The view path hands keyframes straight to WAAPI,\n * so Motion's `x`/`y` shorthands (compiled to\n * `transform` only via the value pipeline) have no\n * effect. Warn and skip - use `transform`/`translate`.\n */\n if (valueName === \"x\" || valueName === \"y\") {\n warnOnce(\n false,\n `animateView() animates view-transition layers with CSS properties; the \"${valueName}\" shorthand has no effect - use transform, e.g. { transform: \"translateX(40px)\" }.`\n )\n continue\n }\n\n /**\n * enter/exit win over new/old on a shared property -\n * skip it here when the gated bucket also defines it.\n */\n if (\n key === \"new\" &&\n enterApplies &&\n target.enter?.keyframes[\n valueName as keyof DOMKeyframesDefinition\n ] != null\n ) {\n continue\n }\n if (\n key === \"old\" &&\n exitApplies &&\n target.exit?.keyframes[\n valueName as keyof DOMKeyframesDefinition\n ] != null\n ) {\n continue\n }\n\n const valueOptions = mergeTransition(\n getValueTransition(\n defaultOptions as any,\n valueName\n ),\n getValueTransition(options as any, valueName)\n )\n\n /**\n * Infer an origin for a single-value keyframe. An\n * `enter` mirrors the matching `exit` value (a\n * defined exit reverses into the enter for free);\n * otherwise the per-type default (opacity 0/1, scale\n * 0.85). No default -> left as-is (animates from the\n * live value).\n *\n * `new`/`old` fire for survivors too, where only the\n * opacity crossfade default applies - a transform\n * default like scale 0.85 would pop a persisting\n * element, so gate it on the layer actually\n * entering/leaving.\n */\n if (!Array.isArray(valueKeyframes)) {\n const exitValue =\n key === \"enter\"\n ? target.exit?.keyframes[\n valueName as keyof DOMKeyframesDefinition\n ]\n : undefined\n const allowDefault =\n valueName === \"opacity\" ||\n (type === \"new\" ? enterApplies : exitApplies)\n const from =\n exitValue != null\n ? Array.isArray(exitValue)\n ? exitValue[exitValue.length - 1]\n : exitValue\n : allowDefault\n ? ORIGIN_DEFAULTS[type]?.[valueName]\n : undefined\n if (from !== undefined) {\n valueKeyframes = [from, valueKeyframes]\n }\n }\n\n /**\n * Resolve stagger function if provided, per element\n * across this subject's resolved layers.\n */\n if (typeof valueOptions.delay === \"function\") {\n valueOptions.delay = valueOptions.delay(\n index,\n total\n )\n }\n\n valueOptions.duration &&= secondsToMilliseconds(\n valueOptions.duration\n )\n\n valueOptions.delay &&= secondsToMilliseconds(\n valueOptions.delay\n )\n\n animations.push(\n new NativeAnimation({\n ...valueOptions,\n element: document.documentElement,\n name: valueName,\n pseudoElement: `::view-transition-${type}(${name})`,\n keyframes: valueKeyframes,\n })\n )\n explicitlyAnimated.add(`${name}:${type}`)\n if (valueName === \"opacity\") {\n opacityAnimated.add(`${name}:${type}`)\n }\n }\n }\n })\n\n /**\n * Handle browser generated animations\n */\n for (const animation of generatedViewAnimations) {\n if (animation.playState === \"finished\") continue\n\n const { effect } = animation\n if (!effect || !(effect instanceof KeyframeEffect)) continue\n\n const { pseudoElement } = effect\n if (!pseudoElement) continue\n\n const name = getViewAnimationLayerInfo(pseudoElement)\n if (!name) continue\n\n const targetDefinition = layerTargets.get(name.layer)\n\n /**\n * We built our own animation for this layer, so drop the\n * browser-generated fade we're replacing. The UA\n * `plus-lighter` blend is a *separate* generated animation on\n * the same pseudo (it sets `mix-blend-mode` in its keyframes):\n * keep it *only* for a true opacity crossfade - both sides\n * fading - so a symmetric crossfade composites without\n * darkening, but a slide/transform (where both layers stay\n * opaque and overlap) doesn't flash bright from the addition.\n */\n if (explicitlyAnimated.has(`${name.layer}:${name.type}`)) {\n const isCrossfade =\n opacityAnimated.has(`${name.layer}:new`) &&\n opacityAnimated.has(`${name.layer}:old`)\n if (\n isCrossfade &&\n effect\n .getKeyframes()\n .some((keyframe) => keyframe.mixBlendMode)\n ) {\n animations.push(new NativeAnimationWrapper(animation))\n } else {\n animation.cancel()\n }\n continue\n }\n\n /**\n * Otherwise retime the browser-generated animation to\n * Motion's timing. This auto-enables the layout (group)\n * morph for any resolved/named target, and applies the\n * default timing to old/new layers we haven't explicitly\n * overridden.\n *\n * group + group-children both follow the layout timing so\n * the nesting container stays in sync with the morph.\n */\n /**\n * A survivor's old + new are the two halves of one\n * `plus-lighter` crossfade. They must share identical timing\n * (so their opacities stay mirrored and sum to 1 - else the\n * additive blend flashes bright wherever both are partly\n * visible) and fade linearly (the bounce belongs on the\n * group's geometry, not the opacity). So time them as the\n * group, rather than via their own - potentially staggered,\n * or enter/exit-derived - old/new options.\n */\n const stagger = layerStagger.get(name.layer)\n const isMorphCrossfade =\n (name.type === \"old\" || name.type === \"new\") &&\n !!stagger?.old &&\n !!stagger?.new\n const timingType =\n name.type.startsWith(\"group\") || isMorphCrossfade\n ? \"group\"\n : name.type\n\n const [index, total] = staggerPosition(\n name.layer,\n timingType\n )\n const transitionName =\n timingType === \"group\" ? \"layout\" : \"\"\n let animationTransition = resolveLayerTransition(\n targetDefinition,\n timingType,\n transitionName,\n index === -1 ? 0 : index,\n total\n )\n\n /**\n * The crossfade should resolve at the spring's *perceptual*\n * (visual) duration - the geometry can keep bouncing, but the\n * opacity shouldn't drag through the settle. So capture\n * `visualDuration` before `applyGeneratorOptions` replaces it\n * with the full overshoot duration, and use it for the fade.\n */\n const visualDuration = animationTransition.visualDuration\n\n animationTransition.duration &&= secondsToMilliseconds(\n animationTransition.duration\n )\n\n animationTransition =\n applyGeneratorOptions(animationTransition)\n\n const duration =\n isMorphCrossfade && visualDuration !== undefined\n ? secondsToMilliseconds(visualDuration)\n : animationTransition.duration\n\n const easing = isMorphCrossfade\n ? \"linear\"\n : (mapEasingToNativeEasing(\n animationTransition.ease,\n animationTransition.duration!\n ) as string)\n\n effect.updateTiming({\n delay: secondsToMilliseconds(\n animationTransition.delay ?? 0\n ),\n duration,\n easing,\n })\n\n animations.push(new NativeAnimationWrapper(animation))\n }\n\n /**\n * Animate each cropped layer's clip corners between the old and\n * new elements, so a cropped morph keeps rounded corners\n * (handling individual per-corner radii).\n */\n cropRadii.forEach((radii, name) => {\n if (!radii.old && !radii.new) return\n\n const target = layerTargets.get(name)\n const [index, total] = staggerPosition(name, \"group\")\n const radiusOptions = resolveLayerTransition(\n target,\n \"group\",\n \"layout\",\n index === -1 ? 0 : index,\n total\n )\n\n radiusOptions.duration &&= secondsToMilliseconds(\n radiusOptions.duration\n )\n radiusOptions.delay &&= secondsToMilliseconds(\n radiusOptions.delay\n )\n\n for (const corner of cornerProps) {\n // `||` (not `??`) so an empty measurement (e.g. an\n // un-rendered element) falls back rather than producing\n // an invalid keyframe.\n const from =\n radii.old?.[corner] || radii.new?.[corner] || \"0px\"\n const to =\n radii.new?.[corner] || radii.old?.[corner] || \"0px\"\n // Skip square corners - nothing to round.\n if (parseFloat(from) === 0 && parseFloat(to) === 0) {\n continue\n }\n\n animations.push(\n new NativeAnimation({\n ...radiusOptions,\n element: document.documentElement,\n name: corner,\n pseudoElement: `::view-transition-group(${name})`,\n keyframes: [from, to],\n })\n )\n }\n })\n\n resolve(new GroupAnimation(animations))\n })\n .catch(() =>\n /**\n * `ready` rejects when the transition is skipped - no visual\n * change, or superseded by an interrupting transition. The DOM\n * update still applied, so settle with no animations rather than\n * surfacing it as an error to an awaiting caller. A genuine\n * failure in `update()` rejects `updateCallbackDone` (already\n * settled by now), so propagate that instead.\n */\n transition.updateCallbackDone.then(\n () => resolve(new GroupAnimation([])),\n reject\n )\n )\n })\n}\n\n/**\n * The options that should time a given generated layer type, so a retimed\n * group/old/new picks up any per-target transition the user provided. Checks\n * the type's buckets in priority order (e.g. `new` before `enter`).\n */\nfunction layerOptions(target: ViewTransitionTarget | undefined, type: string) {\n for (const bucket of typeBuckets[type] ?? []) {\n const options = target?.[bucket]?.options\n if (options) return options\n }\n}\n\n/**\n * Merge a base transition (e.g. the default `options`) with a per-layer/value\n * override. An explicit `duration` on the override must win over an inherited\n * generator's own timing: a spring prefers `visualDuration`, and\n * `spring.applyToOptions` overwrites `duration` with the computed settle time -\n * so without this the override is silently discarded. Dropping the inherited\n * `type`/`visualDuration` makes the layer a plain tween of that duration, unless\n * it asked for its own generator `type`/`visualDuration`.\n */\nfunction mergeTransition(base: any, override: any) {\n const merged = { ...base, ...override }\n\n if (override.duration !== undefined) {\n if (override.visualDuration === undefined) delete mer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CAAC,IAAI;IACvD;AAEA,IAAA,OAAO,MAAM;AACjB;;;;"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { resolveElements } from '../../utils/resolve-elements.mjs';
|
|
2
|
+
|
|
3
|
+
let nameCount = 0;
|
|
4
|
+
/**
|
|
5
|
+
* Generated names live in their own namespace so we can tell a name we own
|
|
6
|
+
* (and must clean up) from an author-defined one - and so a stale generated
|
|
7
|
+
* name left behind by an interrupted transition is re-owned, not mistaken for
|
|
8
|
+
* the author's and leaked.
|
|
9
|
+
*/
|
|
10
|
+
const generatedName = () => `motion-view-${nameCount++}`;
|
|
11
|
+
const isGeneratedName = (name) => name.startsWith("motion-view-");
|
|
12
|
+
/**
|
|
13
|
+
* Tag a captured element with a `view-transition-class` so authors can target
|
|
14
|
+
* its generated layer from CSS (e.g. `::view-transition-group(.hero)`) without
|
|
15
|
+
* the opaque generated name. Tracked in `classed` - separate from the generated
|
|
16
|
+
* names in `assigned` - so cleanup removes the class without ever stripping an
|
|
17
|
+
* author's own inline `view-transition-name`.
|
|
18
|
+
*/
|
|
19
|
+
function tagClass(element, className, classed) {
|
|
20
|
+
if (!className)
|
|
21
|
+
return;
|
|
22
|
+
element.style?.setProperty("view-transition-class", className);
|
|
23
|
+
classed.push(element);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Resolve a selector/Element to elements and ensure each one carries a
|
|
27
|
+
* `view-transition-name` we can target from script.
|
|
28
|
+
*
|
|
29
|
+
* Author-defined names are reused as-is. Elements that are unnamed (or use
|
|
30
|
+
* the browser's `auto`/`match-element`, whose generated name is not exposed
|
|
31
|
+
* to script) are given a unique generated name, set inline so it's captured,
|
|
32
|
+
* and tracked in `assigned` for later cleanup.
|
|
33
|
+
*
|
|
34
|
+
* `registry` maps each Element to its name so the same element keeps its name
|
|
35
|
+
* across both captures (before and after the update), which is what allows a
|
|
36
|
+
* persistent element to animate as a single `group` layer.
|
|
37
|
+
*/
|
|
38
|
+
function assignViewTransitionNames(definition, registry, assigned, forcedNames, className, classed = []) {
|
|
39
|
+
const elements = resolveElements(definition);
|
|
40
|
+
/**
|
|
41
|
+
* The new end of a paired morph: give each element the matching name from
|
|
42
|
+
* the old end (by index) so the two share one layer and morph. If the new
|
|
43
|
+
* end resolves to *more* elements than the old end named, the extras have no
|
|
44
|
+
* counterpart - give them a fresh name so they animate as newcomers rather
|
|
45
|
+
* than being silently left unnamed. We return the names actually assigned
|
|
46
|
+
* (sized to the resolved elements), not the raw `forcedNames`, so stagger
|
|
47
|
+
* totals and the layer set stay in step with what's on the page.
|
|
48
|
+
*/
|
|
49
|
+
if (forcedNames) {
|
|
50
|
+
return elements.map((element, i) => {
|
|
51
|
+
const existing = registry.get(element);
|
|
52
|
+
if (existing)
|
|
53
|
+
return existing;
|
|
54
|
+
const name = forcedNames[i] ?? generatedName();
|
|
55
|
+
element.style?.setProperty("view-transition-name", name);
|
|
56
|
+
assigned.push(element);
|
|
57
|
+
registry.set(element, name);
|
|
58
|
+
tagClass(element, className, classed);
|
|
59
|
+
return name;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Read every current name up front, before assigning any. Interleaving the
|
|
64
|
+
* reads with the inline `setProperty` writes below would dirty styles
|
|
65
|
+
* between reads and force a style recalc per element; batching the reads
|
|
66
|
+
* keeps it to one. Elements already in the registry keep their name and
|
|
67
|
+
* need no read.
|
|
68
|
+
*/
|
|
69
|
+
const currentNames = elements.map((element) => registry.has(element)
|
|
70
|
+
? undefined
|
|
71
|
+
: getComputedStyle(element).getPropertyValue("view-transition-name"));
|
|
72
|
+
return elements.map((element, i) => {
|
|
73
|
+
const existing = registry.get(element);
|
|
74
|
+
if (existing)
|
|
75
|
+
return existing;
|
|
76
|
+
const current = currentNames[i];
|
|
77
|
+
let name;
|
|
78
|
+
if (current &&
|
|
79
|
+
current !== "none" &&
|
|
80
|
+
current !== "auto" &&
|
|
81
|
+
current !== "match-element" &&
|
|
82
|
+
!isGeneratedName(current)) {
|
|
83
|
+
/**
|
|
84
|
+
* The author already named this layer - target it as-is and leave
|
|
85
|
+
* it to them to clean up. `auto`/`match-element` are overridden
|
|
86
|
+
* because their generated name is not exposed to script, and a
|
|
87
|
+
* stale `motion-view-*` (e.g. left by an interrupted transition) is
|
|
88
|
+
* re-owned rather than adopted as an author name and leaked.
|
|
89
|
+
*/
|
|
90
|
+
name = current;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
name = generatedName();
|
|
94
|
+
element.style?.setProperty("view-transition-name", name);
|
|
95
|
+
assigned.push(element);
|
|
96
|
+
}
|
|
97
|
+
registry.set(element, name);
|
|
98
|
+
tagClass(element, className, classed);
|
|
99
|
+
return name;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Remove the `view-transition-name`s we generated and the
|
|
104
|
+
* `view-transition-class`es we applied. Author-defined names are never touched
|
|
105
|
+
* (they're not in `assigned`). Safe to call more than once (e.g. on both a
|
|
106
|
+
* finished and an interrupted transition).
|
|
107
|
+
*/
|
|
108
|
+
function releaseViewTransitionNames(assigned, classed = []) {
|
|
109
|
+
for (const element of assigned) {
|
|
110
|
+
element.style?.removeProperty("view-transition-name");
|
|
111
|
+
}
|
|
112
|
+
for (const element of classed) {
|
|
113
|
+
element.style?.removeProperty("view-transition-class");
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export { assignViewTransitionNames, releaseViewTransitionNames };
|
|
118
|
+
//# sourceMappingURL=assign-names.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assign-names.mjs","sources":["../../../../src/view/utils/assign-names.ts"],"sourcesContent":["import { ElementOrSelector, resolveElements } from \"../../utils/resolve-elements\"\n\nlet nameCount = 0\n\n/**\n * Generated names live in their own namespace so we can tell a name we own\n * (and must clean up) from an author-defined one - and so a stale generated\n * name left behind by an interrupted transition is re-owned, not mistaken for\n * the author's and leaked.\n */\nconst generatedName = () => `motion-view-${nameCount++}`\n\nconst isGeneratedName = (name: string) => name.startsWith(\"motion-view-\")\n\n/**\n * Tag a captured element with a `view-transition-class` so authors can target\n * its generated layer from CSS (e.g. `::view-transition-group(.hero)`) without\n * the opaque generated name. Tracked in `classed` - separate from the generated\n * names in `assigned` - so cleanup removes the class without ever stripping an\n * author's own inline `view-transition-name`.\n */\nfunction tagClass(\n element: Element,\n className: string | undefined,\n classed: Element[]\n) {\n if (!className) return\n ;(element as HTMLElement).style?.setProperty(\n \"view-transition-class\",\n className\n )\n classed.push(element)\n}\n\n/**\n * Resolve a selector/Element to elements and ensure each one carries a\n * `view-transition-name` we can target from script.\n *\n * Author-defined names are reused as-is. Elements that are unnamed (or use\n * the browser's `auto`/`match-element`, whose generated name is not exposed\n * to script) are given a unique generated name, set inline so it's captured,\n * and tracked in `assigned` for later cleanup.\n *\n * `registry` maps each Element to its name so the same element keeps its name\n * across both captures (before and after the update), which is what allows a\n * persistent element to animate as a single `group` layer.\n */\nexport function assignViewTransitionNames(\n definition: ElementOrSelector,\n registry: Map<Element, string>,\n assigned: Element[],\n forcedNames?: string[],\n className?: string,\n classed: Element[] = []\n): string[] {\n const elements = resolveElements(definition)\n\n /**\n * The new end of a paired morph: give each element the matching name from\n * the old end (by index) so the two share one layer and morph. If the new\n * end resolves to *more* elements than the old end named, the extras have no\n * counterpart - give them a fresh name so they animate as newcomers rather\n * than being silently left unnamed. We return the names actually assigned\n * (sized to the resolved elements), not the raw `forcedNames`, so stagger\n * totals and the layer set stay in step with what's on the page.\n */\n if (forcedNames) {\n return elements.map((element, i) => {\n const existing = registry.get(element)\n if (existing) return existing\n\n const name = forcedNames[i] ?? generatedName()\n ;(element as HTMLElement).style?.setProperty(\n \"view-transition-name\",\n name\n )\n assigned.push(element)\n registry.set(element, name)\n tagClass(element, className, classed)\n\n return name\n })\n }\n\n /**\n * Read every current name up front, before assigning any. Interleaving the\n * reads with the inline `setProperty` writes below would dirty styles\n * between reads and force a style recalc per element; batching the reads\n * keeps it to one. Elements already in the registry keep their name and\n * need no read.\n */\n const currentNames = elements.map((element) =>\n registry.has(element)\n ? undefined\n : getComputedStyle(element).getPropertyValue(\"view-transition-name\")\n )\n\n return elements.map((element, i) => {\n const existing = registry.get(element)\n if (existing) return existing\n\n const current = currentNames[i]\n\n let name: string\n if (\n current &&\n current !== \"none\" &&\n current !== \"auto\" &&\n current !== \"match-element\" &&\n !isGeneratedName(current)\n ) {\n /**\n * The author already named this layer - target it as-is and leave\n * it to them to clean up. `auto`/`match-element` are overridden\n * because their generated name is not exposed to script, and a\n * stale `motion-view-*` (e.g. left by an interrupted transition) is\n * re-owned rather than adopted as an author name and leaked.\n */\n name = current\n } else {\n name = generatedName()\n ;(element as HTMLElement).style?.setProperty(\n \"view-transition-name\",\n name\n )\n assigned.push(element)\n }\n\n registry.set(element, name)\n tagClass(element, className, classed)\n\n return name\n })\n}\n\n/**\n * Remove the `view-transition-name`s we generated and the\n * `view-transition-class`es we applied. Author-defined names are never touched\n * (they're not in `assigned`). Safe to call more than once (e.g. on both a\n * finished and an interrupted transition).\n */\nexport function releaseViewTransitionNames(\n assigned: Element[],\n classed: Element[] = []\n): void {\n for (const element of assigned) {\n ;(element as HTMLElement).style?.removeProperty(\"view-transition-name\")\n }\n for (const element of classed) {\n ;(element as HTMLElement).style?.removeProperty(\"view-transition-class\")\n }\n}\n"],"names":[],"mappings":";;AAEA,IAAI,SAAS,GAAG,CAAC;AAEjB;;;;;AAKG;AACH,MAAM,aAAa,GAAG,MAAM,CAAA,YAAA,EAAe,SAAS,EAAE,CAAA,CAAE;AAExD,MAAM,eAAe,GAAG,CAAC,IAAY,KAAK,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC;AAEzE;;;;;;AAMG;AACH,SAAS,QAAQ,CACb,OAAgB,EAChB,SAA6B,EAC7B,OAAkB,EAAA;AAElB,IAAA,IAAI,CAAC,SAAS;QAAE;IACd,OAAuB,CAAC,KAAK,EAAE,WAAW,CACxC,uBAAuB,EACvB,S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;AAE7B,QAAA,MAAM,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC;AAE/B,QAAA,IAAI,IAAY;AAChB,QAAA,IACI,OAAO;AACP,YAAA,OAAO,KAAK,MAAM;AAClB,YAAA,OAAO,KAAK,MAAM;AAClB,YAAA,OAAO,KAAK,eAAe;AAC3B,YAAA,CAAC,eAAe,CAAC,OAAO,CAAC,EAC3B;AACE;;;;;;AAMG;YACH,IAAI,GAAG,OAAO;QAClB;aAAO;YACH,IAAI,GAAG,aAAa,EAAE;YACpB,OAAuB,CAAC,KAAK,EAAE,WAAW,CACxC,sBAAsB,EACtB,IAAI,CACP;AACD,YAAA,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;QAC1B;AAEA,QAAA,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC;AAC3B,QAAA,QAAQ,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC;AAErC,QAAA,OAAO,IAAI;AACf,IAAA,CAAC,CAAC;AACN;AAEA;;;;;AAKG;SACa,0BAA0B,CACtC,QAAmB,EACnB,UAAqB,EAAE,EAAA;AAEvB,IAAA,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;AAC1B,QAAA,OAAuB,CAAC,KAAK,EAAE,cAAc,CAAC,sBAAsB,CAAC;IAC3E;AACA,IAAA,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE;AACzB,QAAA,OAAuB,CAAC,KAAK,EAAE,cAAc,CAAC,uBAAuB,CAAC;IAC5E;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choose-layer-type.mjs","sources":["../../../../src/view/utils/choose-layer-type.ts"],"sourcesContent":["export function chooseLayerType(\n valueName: \"layout\" | \"enter\" | \"exit\" | \"new\" | \"old\"\n): \"group\" | \"old\" | \"new\" {\n if (valueName === \"layout\") return \"group\"\n if (valueName === \"enter\" || valueName === \"new\") return \"new\"\n
|
|
1
|
+
{"version":3,"file":"choose-layer-type.mjs","sources":["../../../../src/view/utils/choose-layer-type.ts"],"sourcesContent":["export function chooseLayerType(\n valueName: \"layout\" | \"enter\" | \"exit\" | \"new\" | \"old\"\n): \"group\" | \"old\" | \"new\" {\n if (valueName === \"layout\") return \"group\"\n if (valueName === \"enter\" || valueName === \"new\") return \"new\"\n return \"old\"\n}\n"],"names":[],"mappings":"AAAM,SAAU,eAAe,CAC3B,SAAsD,EAAA;IAEtD,IAAI,SAAS,KAAK,QAAQ;AAAE,QAAA,OAAO,OAAO;AAC1C,IAAA,IAAI,SAAS,KAAK,OAAO,IAAI,SAAS,KAAK,KAAK;AAAE,QAAA,OAAO,KAAK;AAC9D,IAAA,OAAO,KAAK;AAChB;;;;"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
function getViewAnimationLayerInfo(pseudoElement) {
|
|
2
|
-
const match = pseudoElement.match(
|
|
2
|
+
const match = pseudoElement.match(
|
|
3
|
+
// `group-children` (nested transitions) before `group` so it wins.
|
|
4
|
+
/::view-transition-(old|new|group-children|group|image-pair)\((.*?)\)/);
|
|
3
5
|
if (!match)
|
|
4
6
|
return null;
|
|
5
7
|
return { layer: match[2], type: match[1] };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-layer-info.mjs","sources":["../../../../src/view/utils/get-layer-info.ts"],"sourcesContent":["export function getViewAnimationLayerInfo(pseudoElement: string) {\n const match = pseudoElement.match(\n /::view-transition-(old|new|group|image-pair)\\((.*?)\\)/\n )\n if (!match) return null\n\n return { layer: match[2], type: match[1] }\n}\n"],"names":[],"mappings":"AAAM,SAAU,yBAAyB,CAAC,aAAqB,EAAA;
|
|
1
|
+
{"version":3,"file":"get-layer-info.mjs","sources":["../../../../src/view/utils/get-layer-info.ts"],"sourcesContent":["export function getViewAnimationLayerInfo(pseudoElement: string) {\n const match = pseudoElement.match(\n // `group-children` (nested transitions) before `group` so it wins.\n /::view-transition-(old|new|group-children|group|image-pair)\\((.*?)\\)/\n )\n if (!match) return null\n\n return { layer: match[2], type: match[1] }\n}\n"],"names":[],"mappings":"AAAM,SAAU,yBAAyB,CAAC,aAAqB,EAAA;AAC3D,IAAA,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK;;AAE7B,IAAA,sEAAsE,CACzE;AACD,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,IAAI;AAEvB,IAAA,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE;AAC9C;;;;"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
function filterViewAnimations(animation) {
|
|
2
|
-
const { effect } = animation;
|
|
3
|
-
if (!effect)
|
|
4
|
-
return false;
|
|
5
|
-
return (effect.target === document.documentElement &&
|
|
6
|
-
effect.pseudoElement?.startsWith("::view-transition"));
|
|
7
|
-
}
|
|
8
1
|
function getViewAnimations() {
|
|
9
|
-
return document.getAnimations().filter(
|
|
2
|
+
return document.getAnimations().filter((animation) => {
|
|
3
|
+
const { effect } = animation;
|
|
4
|
+
return (!!effect &&
|
|
5
|
+
effect.target === document.documentElement &&
|
|
6
|
+
effect.pseudoElement?.startsWith("::view-transition"));
|
|
7
|
+
});
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
export { getViewAnimations };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-view-animations.mjs","sources":["../../../../src/view/utils/get-view-animations.ts"],"sourcesContent":["function
|
|
1
|
+
{"version":3,"file":"get-view-animations.mjs","sources":["../../../../src/view/utils/get-view-animations.ts"],"sourcesContent":["export function getViewAnimations() {\n return document.getAnimations().filter((animation) => {\n const { effect } = animation\n return (\n !!effect &&\n effect.target === document.documentElement &&\n (effect as KeyframeEffect).pseudoElement?.startsWith(\n \"::view-transition\"\n )\n )\n })\n}\n"],"names":[],"mappings":"SAAgB,iBAAiB,GAAA;IAC7B,OAAO,QAAQ,CAAC,aAAa,EAAE,CAAC,MAAM,CAAC,CAAC,SAAS,KAAI;AACjD,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS;QAC5B,QACI,CAAC,CAAC,MAAM;AACR,YAAA,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,eAAe;YACzC,MAAyB,CAAC,aAAa,EAAE,UAAU,CAChD,mBAAmB,CACtB;AAET,IAAA,CAAC,CAAC;AACN;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3346,43 +3346,21 @@ declare function resize(target: ElementOrSelector, onResize: ResizeHandler<Eleme
|
|
|
3346
3346
|
type Update = (progress: number) => void;
|
|
3347
3347
|
declare function observeTimeline(update: Update, timeline: ProgressTimeline): () => void;
|
|
3348
3348
|
|
|
3349
|
-
declare
|
|
3350
|
-
type StepNames = (typeof stepsOrder)[number];
|
|
3351
|
-
|
|
3352
|
-
interface Summary {
|
|
3353
|
-
min: number;
|
|
3354
|
-
max: number;
|
|
3355
|
-
avg: number;
|
|
3356
|
-
}
|
|
3357
|
-
type FrameloopStatNames = "rate" | StepNames;
|
|
3358
|
-
interface Stats<T> {
|
|
3359
|
-
frameloop: {
|
|
3360
|
-
[key in FrameloopStatNames]: T;
|
|
3361
|
-
};
|
|
3362
|
-
animations: {
|
|
3363
|
-
mainThread: T;
|
|
3364
|
-
waapi: T;
|
|
3365
|
-
layout: T;
|
|
3366
|
-
};
|
|
3367
|
-
layoutProjection: {
|
|
3368
|
-
nodes: T;
|
|
3369
|
-
calculatedTargetDeltas: T;
|
|
3370
|
-
calculatedProjections: T;
|
|
3371
|
-
};
|
|
3372
|
-
}
|
|
3373
|
-
type StatsBuffer = number[];
|
|
3374
|
-
type FrameStats = Stats<number>;
|
|
3375
|
-
type StatsRecording = Stats<StatsBuffer>;
|
|
3376
|
-
type StatsSummary = Stats<Summary>;
|
|
3377
|
-
|
|
3378
|
-
declare function reportStats(): StatsSummary;
|
|
3379
|
-
declare function recordStats(): typeof reportStats;
|
|
3349
|
+
declare function recordStats(): void;
|
|
3380
3350
|
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
}
|
|
3351
|
+
interface LayoutProjectionMetrics {
|
|
3352
|
+
nodes: number;
|
|
3353
|
+
calculatedTargetDeltas: number;
|
|
3354
|
+
calculatedProjections: number;
|
|
3355
|
+
}
|
|
3356
|
+
interface LayoutProjectionStats {
|
|
3357
|
+
nodes: number[];
|
|
3358
|
+
calculatedTargetDeltas: number[];
|
|
3359
|
+
calculatedProjections: number[];
|
|
3360
|
+
}
|
|
3361
|
+
interface StatsRecording {
|
|
3362
|
+
layoutProjection: LayoutProjectionStats;
|
|
3363
|
+
}
|
|
3386
3364
|
|
|
3387
3365
|
type InactiveStatsBuffer = {
|
|
3388
3366
|
value: null;
|
|
@@ -3390,11 +3368,7 @@ type InactiveStatsBuffer = {
|
|
|
3390
3368
|
};
|
|
3391
3369
|
type ActiveStatsBuffer = {
|
|
3392
3370
|
value: StatsRecording;
|
|
3393
|
-
addProjectionMetrics: (metrics:
|
|
3394
|
-
nodes: number;
|
|
3395
|
-
calculatedTargetDeltas: number;
|
|
3396
|
-
calculatedProjections: number;
|
|
3397
|
-
}) => void;
|
|
3371
|
+
addProjectionMetrics: (metrics: LayoutProjectionMetrics) => void;
|
|
3398
3372
|
};
|
|
3399
3373
|
declare const statsBuffer: InactiveStatsBuffer | ActiveStatsBuffer;
|
|
3400
3374
|
|
|
@@ -3965,8 +3939,17 @@ type ViewTransitionAnimationDefinition = {
|
|
|
3965
3939
|
};
|
|
3966
3940
|
type ViewTransitionTarget = {
|
|
3967
3941
|
layout?: ViewTransitionAnimationDefinition;
|
|
3942
|
+
/**
|
|
3943
|
+
* Presence-gated: `enter` animates a pure newcomer's new view, `exit` a
|
|
3944
|
+
* pure leaver's old view. A survivor (present in both snapshots) gets
|
|
3945
|
+
* neither - it just morphs.
|
|
3946
|
+
*/
|
|
3968
3947
|
enter?: ViewTransitionAnimationDefinition;
|
|
3969
3948
|
exit?: ViewTransitionAnimationDefinition;
|
|
3949
|
+
/**
|
|
3950
|
+
* View-targeted (ungated): `new`/`old` animate the new/old view whenever it
|
|
3951
|
+
* exists - including a survivor's, for crossfades and slide-throughs.
|
|
3952
|
+
*/
|
|
3970
3953
|
new?: ViewTransitionAnimationDefinition;
|
|
3971
3954
|
old?: ViewTransitionAnimationDefinition;
|
|
3972
3955
|
};
|
|
@@ -3978,22 +3961,84 @@ type ViewTransitionTargetDefinition = string | Element;
|
|
|
3978
3961
|
declare class ViewTransitionBuilder {
|
|
3979
3962
|
private currentSubject;
|
|
3980
3963
|
targets: Map<ViewTransitionTargetDefinition, ViewTransitionTarget>;
|
|
3964
|
+
/**
|
|
3965
|
+
* Definitions that must be resolved to elements (and assigned a
|
|
3966
|
+
* `view-transition-name`) rather than treated as pre-named layers.
|
|
3967
|
+
*/
|
|
3968
|
+
resolveDefs: Set<ViewTransitionTargetDefinition>;
|
|
3969
|
+
/**
|
|
3970
|
+
* Subjects opted out of the default crop (clip + object-fit: cover +
|
|
3971
|
+
* animated corner radii) via `.crop(false)`.
|
|
3972
|
+
*/
|
|
3973
|
+
noCrop: Set<ViewTransitionTargetDefinition>;
|
|
3974
|
+
/**
|
|
3975
|
+
* Subjects paired with a different new-snapshot target (the second `.add()`
|
|
3976
|
+
* argument), so two distinct elements share one name and morph into each
|
|
3977
|
+
* other - a shared-element transition.
|
|
3978
|
+
*/
|
|
3979
|
+
pairs: Map<ViewTransitionTargetDefinition, ViewTransitionTargetDefinition>;
|
|
3980
|
+
/**
|
|
3981
|
+
* A `view-transition-class` to apply to each subject's resolved elements,
|
|
3982
|
+
* so authors can target the generated layers from CSS by class rather than
|
|
3983
|
+
* the opaque generated name.
|
|
3984
|
+
*/
|
|
3985
|
+
classNames: Map<ViewTransitionTargetDefinition, string>;
|
|
3981
3986
|
update: () => void | Promise<void>;
|
|
3982
3987
|
options: ViewTransitionOptions;
|
|
3983
3988
|
notifyReady: (value: GroupAnimation) => void;
|
|
3989
|
+
notifyReject: (error: unknown) => void;
|
|
3984
3990
|
private readyPromise;
|
|
3985
3991
|
constructor(update: () => void | Promise<void>, options?: ViewTransitionOptions);
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3992
|
+
/**
|
|
3993
|
+
* Target elements resolved from a selector or Element, each assigned a
|
|
3994
|
+
* `view-transition-name` automatically.
|
|
3995
|
+
*
|
|
3996
|
+
* Passing a second target pairs them: the first is resolved in the old
|
|
3997
|
+
* snapshot and the second in the new, sharing one name so two *different*
|
|
3998
|
+
* elements morph into each other (e.g. `.add(card, ".modal")`). Symmetric -
|
|
3999
|
+
* pass them the other way round to morph back.
|
|
4000
|
+
*/
|
|
4001
|
+
add(subject: ViewTransitionTargetDefinition, newSubject?: ViewTransitionTargetDefinition): this;
|
|
4002
|
+
/**
|
|
4003
|
+
* Morphs are clipped + `object-fit: cover` (and their corners animate)
|
|
4004
|
+
* by default. Call `.crop(false)` to opt this subject out and fall back
|
|
4005
|
+
* to the browser default (which overflows on aspect-ratio change).
|
|
4006
|
+
*/
|
|
4007
|
+
crop(enabled?: boolean): this;
|
|
4008
|
+
/**
|
|
4009
|
+
* Tag this subject's generated layers with a `view-transition-class`, so
|
|
4010
|
+
* they can be targeted from CSS - `::view-transition-group(.name)`,
|
|
4011
|
+
* `::view-transition-old/new(.name)`, `::view-transition-image-pair(.name)`
|
|
4012
|
+
* - without the opaque generated `view-transition-name`. Because `.add()`
|
|
4013
|
+
* can match many elements, a shared class targets them all at once (and,
|
|
4014
|
+
* for a pair, both ends). The escape hatch for z-index / custom keyframes
|
|
4015
|
+
* on a morph layer.
|
|
4016
|
+
*/
|
|
4017
|
+
class(name: string): this;
|
|
4018
|
+
/**
|
|
4019
|
+
* Set the transition for this subject's morph. The morph is enabled
|
|
4020
|
+
* automatically by `.add()`; this just customises its timing (duration,
|
|
4021
|
+
* easing, a `delay`/`stagger`, …). On the implicit `root` subject it also
|
|
4022
|
+
* opts the page into the transition (the root crossfade).
|
|
4023
|
+
*/
|
|
4024
|
+
layout(options?: AnimationOptions): this;
|
|
3990
4025
|
enter(keyframes: DOMKeyframesDefinition, options?: AnimationOptions): this;
|
|
3991
4026
|
exit(keyframes: DOMKeyframesDefinition, options?: AnimationOptions): this;
|
|
3992
|
-
|
|
4027
|
+
/**
|
|
4028
|
+
* Animate the new view directly, whether the element is appearing or
|
|
4029
|
+
* persisting (unlike `.enter()`, which only fires for a pure newcomer).
|
|
4030
|
+
* Pair with `.old()` for a crossfade or slide-through.
|
|
4031
|
+
*/
|
|
4032
|
+
new(keyframes: DOMKeyframesDefinition, options?: AnimationOptions): this;
|
|
4033
|
+
/**
|
|
4034
|
+
* Animate the old view directly, whether the element is leaving or
|
|
4035
|
+
* persisting (unlike `.exit()`, which only fires for a pure leaver).
|
|
4036
|
+
*/
|
|
4037
|
+
old(keyframes: DOMKeyframesDefinition, options?: AnimationOptions): this;
|
|
3993
4038
|
updateTarget(target: "enter" | "exit" | "layout" | "new" | "old", keyframes: DOMKeyframesDefinition, options?: AnimationOptions): void;
|
|
3994
4039
|
then(resolve: () => void, reject?: () => void): Promise<void>;
|
|
3995
4040
|
}
|
|
3996
|
-
declare function animateView(update: () => void | Promise<void>,
|
|
4041
|
+
declare function animateView(update: () => void | Promise<void>, options?: ViewTransitionOptions): ViewTransitionBuilder;
|
|
3997
4042
|
|
|
3998
4043
|
declare function getViewAnimationLayerInfo(pseudoElement: string): {
|
|
3999
4044
|
layer: string;
|
|
@@ -5180,12 +5225,20 @@ declare class LayoutAnimationBuilder {
|
|
|
5180
5225
|
private notifyReady;
|
|
5181
5226
|
private rejectReady;
|
|
5182
5227
|
private readyPromise;
|
|
5183
|
-
|
|
5228
|
+
private tracked;
|
|
5229
|
+
private restorePoints;
|
|
5230
|
+
private updateError;
|
|
5231
|
+
constructor(scope: LayoutAnimationScope, updateDom: () => void | Promise<void>, defaultOptions?: AnimationOptions | undefined);
|
|
5184
5232
|
shared(id: string, transition: AnimationOptions): this;
|
|
5185
5233
|
then(resolve: LayoutBuilderResolve, reject?: LayoutBuilderReject): Promise<void>;
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5234
|
+
transitionFor(element: HTMLElement): Transition | undefined;
|
|
5235
|
+
adopt(element: HTMLElement, node: IProjectionNode): void;
|
|
5236
|
+
collectTargets(): HTMLElement[];
|
|
5237
|
+
runUpdate(): Promise<void> | undefined;
|
|
5238
|
+
reconcileAdditions(newMemberIds: Set<string>): void;
|
|
5239
|
+
reconcileRemovals(newMemberIds: Set<string>): void;
|
|
5240
|
+
getRoot(): IProjectionNode | undefined;
|
|
5241
|
+
finalize(): void;
|
|
5189
5242
|
}
|
|
5190
5243
|
declare function parseAnimateLayoutArgs(scopeOrUpdateDom: ElementOrSelector | (() => void), updateDomOrOptions?: (() => void) | AnimationOptions, options?: AnimationOptions): {
|
|
5191
5244
|
scope: Element | Document;
|
|
@@ -5206,4 +5259,4 @@ declare const sync: Batcher;
|
|
|
5206
5259
|
*/
|
|
5207
5260
|
declare const cancelSync: Record<string, (process: Process) => void>;
|
|
5208
5261
|
|
|
5209
|
-
export { type AccelerateConfig, type AcceptedAnimations, type ActiveStatsBuffer, 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 ElementOrSelector, type EventInfo, type EventOptions, Feature, type FeatureClass, FlatTree, type FollowValueOptions, type FrameData, type
|
|
5262
|
+
export { type AccelerateConfig, type AcceptedAnimations, type ActiveStatsBuffer, 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 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 MotionValueEventCallbacks, type MotionValueOptions, 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 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, addScaleCorrector, addStyleValue, addValueToWillChange, alpha, analyseComplexValue, animateMotionValue, animateSingleValue, animateTarget, animateValue, 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, createGeneratorEasing, createProjectionNode, createRenderBatcher, cubicBezierAsString, defaultEasing, defaultOffset, defaultTransformValue, defaultValueTypes, degrees, delay, delayInSeconds, dimensionValueTypes, eachAxis, fillOffset, fillWildcards, findDimensionValueType, findValueType, flushKeyframeResolvers, followValue, frame, frameData, frameSteps, generateLinearEasing, getAnimatableNone, getAnimationMap, getComputedStyle, getDefaultTransition, getDefaultValueType, getFeatureDefinitions, getFinalKeyframe, getMixer, getOptimisedAppearId, getOriginIndex, getValueAsType, getValueTransition, getVariableValue, getVariantContext, getViewAnimationLayerInfo, getViewAnimations, globalProjectionState, has2DTranslate, 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, observeTimeline, optimizedAppearDataAttribute, optimizedAppearDataId, parseAnimateLayoutArgs, parseCSSVariable, parseValueFromTransform, percent, pixelsToPercent, positionalKeys, prefersReducedMotion, press, progressPercentage, propEffect, propagateDirtyNodes, px, readTransformValue, recordStats, removeAxisDelta, removeAxisTransforms, removeBoxTransforms, 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, supportedWaapiEasing, supportsBrowserAnimation, supportsFlags, supportsLinearEasing, supportsPartialKeyframes, supportsScrollTimeline, supportsViewTimeline, svgEffect, sync, testValueType, time, transform, transformAxis, transformBox, transformBoxPoints, transformPropOrder, transformProps, transformValue, transformValueTypes, translateAxis, updateMotionValuesFromProps, variantPriorityOrder, variantProps, vh, visualElementStore, vw };
|