motion-dom 12.41.0 → 12.42.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 +182 -91
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/view/index.mjs +41 -8
- package/dist/es/view/index.mjs.map +1 -1
- package/dist/es/view/start.mjs +111 -81
- package/dist/es/view/start.mjs.map +1 -1
- package/dist/es/view/utils/assign-names.mjs +30 -2
- package/dist/es/view/utils/assign-names.mjs.map +1 -1
- package/dist/index.d.ts +36 -6
- package/dist/motion-dom.dev.js +182 -91
- package/dist/motion-dom.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
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 merged.visualDuration\n if (override.type === undefined) delete merged.type\n }\n\n return merged\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAU;AAE1E;;;;;AAKG;AACH,MAAM,WAAW,GAAmD;I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AAA,wBAAA,EAA2B,IAAI,CAAA,CAAA,CAAG;AACjD,wBAAA,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;AACxB,qBAAA,CAAC,CACL;gBACL;AACJ,YAAA,CAAC,CAAC;AAEF,YAAA,OAAO,CAAC,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;AAC3C,QAAA,CAAC;aACA,KAAK,CAAC;AACH;;;;;;;AAOG;QACH,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAC9B,MAAM,OAAO,CAAC,IAAI,cAAc,CAAC,EAAE,CAAC,CAAC,EACrC,MAAM,CACT,CACJ;AACT,IAAA,CAAC,CAAC;AACN;AAEA;;;;AAIG;AACH,SAAS,YAAY,CAAC,MAAwC,EAAE,IAAY,EAAA;IACxE,KAAK,MAAM,MAAM,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE;QAC1C,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,OAAO;AACzC,QAAA,IAAI,OAAO;AAAE,YAAA,OAAO,OAAO;IAC/B;AACJ;AAEA;;;;;;;;AAQG;AACH,SAAS,eAAe,CAAC,IAAS,EAAE,QAAa,EAAA;IAC7C,MAAM,MAAM,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAE;AAEvC,IAAA,IAAI,QAAQ,CAAC,QAAQ,KAAK,SAAS,EAAE;AACjC,QAAA,IAAI,QAAQ,CAAC,cAAc,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC,cAAc;AACvE,QAAA,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC,IAAI;IACvD;AAEA,IAAA,OAAO,MAAM;AACjB;;;;"}
|
|
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\n/**\n * How much two box aspect ratios must differ before a morph is treated as\n * aspect-changing (and so worth cropping). Matches the projection engine's\n * `preserve-aspect` threshold, so small layout jitter doesn't trigger a crop.\n */\nconst ASPECT_TOLERANCE = 0.2\n\nexport function startViewAnimation(\n builder: ViewTransitionBuilder\n): Promise<GroupAnimation> {\n const {\n update,\n targets,\n resolveDefs,\n cropOverride,\n pairs,\n classNames,\n flatGroups,\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 /**\n * Elements we set a `view-transition-group` on (for nesting), tracked for\n * cleanup. `clipChildren` collects the names of nested parents that clip in\n * the live layout, so their `::view-transition-group-children` is clipped\n * through the transition - not just once the live DOM takes back over.\n */\n const grouped: Element[] = []\n const clipChildren = new Set<string>()\n const layerTargets = new Map<string, ViewTransitionTarget>()\n const croppedNames = new Set<string>()\n /**\n * Each layer's explicit `.crop(true | false)` override (by resolved name),\n * so `finalizeCrop` can let an author's choice win over the morph default.\n */\n const cropForName = new Map<string, boolean>()\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 /**\n * Nest each resolved layer under its DOM-ancestor layer by default\n * (`contain`), so an ancestor's clip/transform/opacity reach it\n * through the transition; `.group(false)` opts a subject out (`none`)\n * to stay flat and escape. Skipped for root / pre-named layers, which\n * aren't elements we resolve and style.\n */\n const group =\n definition === \"root\" || !resolveDefs.has(definition)\n ? undefined\n : flatGroups.has(definition)\n ? \"none\"\n : \"contain\"\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 group,\n grouped,\n clipChildren\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 group,\n grouped,\n clipChildren\n )\n }\n } else {\n names = assignViewTransitionNames(\n definition as ElementOrSelector,\n nameRegistry,\n assigned,\n undefined,\n className,\n classed,\n group,\n grouped,\n clipChildren\n )\n }\n\n // Record any explicit `.crop(true | false)` per resolved name; the\n // crop set itself is computed later by `finalizeCrop` (it needs both\n // snapshots to know which morphs change aspect ratio).\n const override = cropOverride.get(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 (override !== undefined) cropForName.set(name, override)\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 * Each layer's box size per snapshot, so `finalizeCrop` can tell whether a\n * morph's aspect ratio changed (the only case worth cropping).\n */\n const cropBox = new Map<\n string,\n {\n old?: { width: number; height: number }\n new?: { width: number; height: number }\n }\n >()\n\n const measureLayers = (phase: \"old\" | \"new\") =>\n nameRegistry.forEach((name, element) => {\n const rect = (element as HTMLElement).getBoundingClientRect?.()\n if (rect && rect.height) {\n const entry = cropBox.get(name) ?? {}\n entry[phase] = { width: rect.width, height: rect.height }\n cropBox.set(name, entry)\n }\n })\n\n /**\n * With both snapshots measured, settle which layers crop. The default crops\n * only a morph whose aspect ratio *changes* between snapshots - the one case\n * where `object-fit: cover` does real work. A same-aspect morph or a\n * fade-only layer is left uncropped: its corners scale naturally (no flash\n * from squaring, no `overflow: clip` eating its shadow) and a backdrop can't\n * be clipped to nothing. An explicit `.crop(true | false)` overrides either\n * way. Runs after both snapshots are measured, since aspect needs both.\n */\n const finalizeCrop = () => {\n croppedNames.clear()\n for (const name of layerStagger.keys()) {\n if (name === \"root\") continue\n // An explicit `.crop(true | false)` wins; otherwise crop a morph\n // whose aspect ratio changed.\n if (cropForName.get(name) ?? aspectChanged(name)) {\n croppedNames.add(name)\n }\n }\n }\n\n /**\n * Whether a layer is a morph whose box aspect ratio changed between\n * snapshots (beyond a small tolerance). Fade-only layers (one snapshot) are\n * never \"changed\".\n */\n const aspectChanged = (name: string) => {\n const box = cropBox.get(name)\n if (!box?.old || !box?.new || !box.old.height || !box.new.height) {\n return false\n }\n return (\n Math.abs(\n box.old.width / box.old.height -\n box.new.width / box.new.height\n ) > ASPECT_TOLERANCE\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).\n *\n * `css.commit` replaces rather than appends, so we re-set the full rule set\n * each call - the crop rules are only known after `finalizeCrop` runs in the\n * update callback, so the second call writes them.\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 /**\n * Clip the nested children of any layer that clips in the live layout,\n * so a wrapper crops its child for the whole morph (mirroring the DOM)\n * rather than only at the live-DOM handoff. No-op on browsers without\n * nested view-transition groups.\n */\n clipChildren.forEach((name) => {\n css.set(`::view-transition-group-children(${name})`, {\n overflow: \"clip\",\n })\n })\n\n css.commit() // Write\n }\n\n const cleanup = () => {\n releaseViewTransitionNames(assigned, classed, grouped)\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 them. With both snapshots measured we can\n * settle the crop set (aspect-changing morphs + forced).\n */\n resolveLayers(\"new\")\n measureLayers(\"new\")\n finalizeCrop()\n\n /**\n * Re-commit the crop CSS unconditionally: `finalizeCrop` is computed\n * here (after both snapshots are measured), so the clip rules must be\n * (re)written to match the settled set.\n */\n commitViewCSS()\n }\n\n let transition: ViewTransition\n try {\n resolveLayers(\"old\")\n /**\n * Measure the old snapshot against the optimistic crop set (the new\n * snapshot doesn't exist yet, so aspect change can't be known here;\n * `finalizeCrop` settles it post-update).\n */\n measureLayers(\"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 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 merged.visualDuration\n if (override.type === undefined) delete merged.type\n }\n\n return merged\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,E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SAAS,CAAC,CAAC;YAC1D;AAEA,YAAA,OAAO,CAAC,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;AAC3C,QAAA,CAAC;aACA,KAAK,CAAC;AACH;;;;;;;AAOG;QACH,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAC9B,MAAM,OAAO,CAAC,IAAI,cAAc,CAAC,EAAE,CAAC,CAAC,EACrC,MAAM,CACT,CACJ;AACT,IAAA,CAAC,CAAC;AACN;AAEA;;;;AAIG;AACH,SAAS,YAAY,CAAC,MAAwC,EAAE,IAAY,EAAA;IACxE,KAAK,MAAM,MAAM,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE;QAC1C,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,OAAO;AACzC,QAAA,IAAI,OAAO;AAAE,YAAA,OAAO,OAAO;IAC/B;AACJ;AAEA;;;;;;;;AAQG;AACH,SAAS,eAAe,CAAC,IAAS,EAAE,QAAa,EAAA;IAC7C,MAAM,MAAM,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAE;AAEvC,IAAA,IAAI,QAAQ,CAAC,QAAQ,KAAK,SAAS,EAAE;AACjC,QAAA,IAAI,QAAQ,CAAC,cAAc,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC,cAAc;AACvE,QAAA,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC,IAAI;IACvD;AAEA,IAAA,OAAO,MAAM;AACjB;;;;"}
|
|
@@ -22,6 +22,29 @@ function tagClass(element, className, classed) {
|
|
|
22
22
|
element.style?.setProperty("view-transition-class", className);
|
|
23
23
|
classed.push(element);
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Set the element's `view-transition-group` so its layer reconstructs the DOM
|
|
27
|
+
* hierarchy in the pseudo-tree (`contain`) - or stays flat (`none`). Tracked in
|
|
28
|
+
* `grouped` for cleanup. When the element clips (any non-`visible` overflow) its
|
|
29
|
+
* name is recorded in `clipChildren` so the caller can clip the nested children
|
|
30
|
+
* (`::view-transition-group-children(name)`), mirroring the live clip through
|
|
31
|
+
* the whole transition rather than only at the live-DOM handoff.
|
|
32
|
+
*
|
|
33
|
+
* Ignored by browsers without nested view-transition groups, where it harmlessly
|
|
34
|
+
* degrades to the flat default.
|
|
35
|
+
*/
|
|
36
|
+
function applyGroup(element, name, group, grouped, clipChildren) {
|
|
37
|
+
if (!group)
|
|
38
|
+
return;
|
|
39
|
+
element.style?.setProperty("view-transition-group", group);
|
|
40
|
+
grouped.push(element);
|
|
41
|
+
if (group !== "none" && clipChildren) {
|
|
42
|
+
const style = getComputedStyle(element);
|
|
43
|
+
if (style.overflowX !== "visible" || style.overflowY !== "visible") {
|
|
44
|
+
clipChildren.add(name);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
25
48
|
/**
|
|
26
49
|
* Resolve a selector/Element to elements and ensure each one carries a
|
|
27
50
|
* `view-transition-name` we can target from script.
|
|
@@ -35,7 +58,7 @@ function tagClass(element, className, classed) {
|
|
|
35
58
|
* across both captures (before and after the update), which is what allows a
|
|
36
59
|
* persistent element to animate as a single `group` layer.
|
|
37
60
|
*/
|
|
38
|
-
function assignViewTransitionNames(definition, registry, assigned, forcedNames, className, classed = []) {
|
|
61
|
+
function assignViewTransitionNames(definition, registry, assigned, forcedNames, className, classed = [], group, grouped = [], clipChildren) {
|
|
39
62
|
const elements = resolveElements(definition);
|
|
40
63
|
/**
|
|
41
64
|
* The new end of a paired morph: give each element the matching name from
|
|
@@ -56,6 +79,7 @@ function assignViewTransitionNames(definition, registry, assigned, forcedNames,
|
|
|
56
79
|
assigned.push(element);
|
|
57
80
|
registry.set(element, name);
|
|
58
81
|
tagClass(element, className, classed);
|
|
82
|
+
applyGroup(element, name, group, grouped, clipChildren);
|
|
59
83
|
return name;
|
|
60
84
|
});
|
|
61
85
|
}
|
|
@@ -96,6 +120,7 @@ function assignViewTransitionNames(definition, registry, assigned, forcedNames,
|
|
|
96
120
|
}
|
|
97
121
|
registry.set(element, name);
|
|
98
122
|
tagClass(element, className, classed);
|
|
123
|
+
applyGroup(element, name, group, grouped, clipChildren);
|
|
99
124
|
return name;
|
|
100
125
|
});
|
|
101
126
|
}
|
|
@@ -105,13 +130,16 @@ function assignViewTransitionNames(definition, registry, assigned, forcedNames,
|
|
|
105
130
|
* (they're not in `assigned`). Safe to call more than once (e.g. on both a
|
|
106
131
|
* finished and an interrupted transition).
|
|
107
132
|
*/
|
|
108
|
-
function releaseViewTransitionNames(assigned, classed = []) {
|
|
133
|
+
function releaseViewTransitionNames(assigned, classed = [], grouped = []) {
|
|
109
134
|
for (const element of assigned) {
|
|
110
135
|
element.style?.removeProperty("view-transition-name");
|
|
111
136
|
}
|
|
112
137
|
for (const element of classed) {
|
|
113
138
|
element.style?.removeProperty("view-transition-class");
|
|
114
139
|
}
|
|
140
|
+
for (const element of grouped) {
|
|
141
|
+
element.style?.removeProperty("view-transition-group");
|
|
142
|
+
}
|
|
115
143
|
}
|
|
116
144
|
|
|
117
145
|
export { assignViewTransitionNames, releaseViewTransitionNames };
|
|
@@ -1 +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,SAAS,CACZ;AACD,IAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;AACzB;AAEA;;;;;;;;;;;;AAYG;AACG,SAAU,yBAAyB,CACrC,UAA6B,EAC7B,QAA8B,EAC9B,QAAmB,EACnB,WAAsB,EACtB,SAAkB,EAClB,UAAqB,EAAE,EAAA;AAEvB,IAAA,MAAM,QAAQ,GAAG,eAAe,CAAC,UAAU,C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;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
|
+
{"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 * Set the element's `view-transition-group` so its layer reconstructs the DOM\n * hierarchy in the pseudo-tree (`contain`) - or stays flat (`none`). Tracked in\n * `grouped` for cleanup. When the element clips (any non-`visible` overflow) its\n * name is recorded in `clipChildren` so the caller can clip the nested children\n * (`::view-transition-group-children(name)`), mirroring the live clip through\n * the whole transition rather than only at the live-DOM handoff.\n *\n * Ignored by browsers without nested view-transition groups, where it harmlessly\n * degrades to the flat default.\n */\nfunction applyGroup(\n element: Element,\n name: string,\n group: string | undefined,\n grouped: Element[],\n clipChildren?: Set<string>\n) {\n if (!group) return\n ;(element as HTMLElement).style?.setProperty(\"view-transition-group\", group)\n grouped.push(element)\n\n if (group !== \"none\" && clipChildren) {\n const style = getComputedStyle(element)\n if (style.overflowX !== \"visible\" || style.overflowY !== \"visible\") {\n clipChildren.add(name)\n }\n }\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 group?: string,\n grouped: Element[] = [],\n clipChildren?: Set<string>\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 applyGroup(element, name, group, grouped, clipChildren)\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 applyGroup(element, name, group, grouped, clipChildren)\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 grouped: 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 for (const element of grouped) {\n ;(element as HTMLElement).style?.remove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AAK,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;QACrC,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,CAAC;AAEvD,QAAA,OAAO,IAAI;AACf,IAAA,CAAC,CAAC;AACN;AAEA;;;;;AAKG;AACG,SAAU,0BAA0B,CACtC,QAAmB,EACnB,OAAA,GAAqB,EAAE,EACvB,OAAA,GAAqB,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;AACA,IAAA,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE;AACzB,QAAA,OAAuB,CAAC,KAAK,EAAE,cAAc,CAAC,uBAAuB,CAAC;IAC5E;AACJ;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3967,10 +3967,12 @@ declare class ViewTransitionBuilder {
|
|
|
3967
3967
|
*/
|
|
3968
3968
|
resolveDefs: Set<ViewTransitionTargetDefinition>;
|
|
3969
3969
|
/**
|
|
3970
|
-
*
|
|
3971
|
-
* animated corner radii)
|
|
3970
|
+
* Per-subject crop override: `true` forces the crop (clip + object-fit:
|
|
3971
|
+
* cover + animated corner radii) on, `false` forces it off. A subject with
|
|
3972
|
+
* no entry uses the default - crop only a genuine morph (a layer present in
|
|
3973
|
+
* both snapshots), so a fade-only enter/exit isn't clipped to nothing.
|
|
3972
3974
|
*/
|
|
3973
|
-
|
|
3975
|
+
cropOverride: Map<ViewTransitionTargetDefinition, boolean>;
|
|
3974
3976
|
/**
|
|
3975
3977
|
* Subjects paired with a different new-snapshot target (the second `.add()`
|
|
3976
3978
|
* argument), so two distinct elements share one name and morph into each
|
|
@@ -3983,6 +3985,14 @@ declare class ViewTransitionBuilder {
|
|
|
3983
3985
|
* the opaque generated name.
|
|
3984
3986
|
*/
|
|
3985
3987
|
classNames: Map<ViewTransitionTargetDefinition, string>;
|
|
3988
|
+
/**
|
|
3989
|
+
* Subjects opted out of automatic group nesting via `.group(false)`. Their
|
|
3990
|
+
* layer stays a flat top-level group (`view-transition-group: none`) instead
|
|
3991
|
+
* of nesting under its DOM-ancestor layer - so it animates independently and
|
|
3992
|
+
* escapes an ancestor's clip/transform (e.g. an element that lifts out of a
|
|
3993
|
+
* card and flies across, which nesting would clip to the card).
|
|
3994
|
+
*/
|
|
3995
|
+
flatGroups: Set<ViewTransitionTargetDefinition>;
|
|
3986
3996
|
update: () => void | Promise<void>;
|
|
3987
3997
|
options: ViewTransitionOptions;
|
|
3988
3998
|
notifyReady: (value: GroupAnimation) => void;
|
|
@@ -4000,11 +4010,31 @@ declare class ViewTransitionBuilder {
|
|
|
4000
4010
|
*/
|
|
4001
4011
|
add(subject: ViewTransitionTargetDefinition, newSubject?: ViewTransitionTargetDefinition): this;
|
|
4002
4012
|
/**
|
|
4003
|
-
*
|
|
4004
|
-
*
|
|
4005
|
-
*
|
|
4013
|
+
* Control this subject's crop (clip + `object-fit: cover` + animated
|
|
4014
|
+
* corners). By default a subject auto-crops only when it actually morphs -
|
|
4015
|
+
* present in both snapshots (a survivor, or an `.add(a, b)` pair). A
|
|
4016
|
+
* fade-only enter/exit has no second box to crop against, so it's left to
|
|
4017
|
+
* the browser default; in particular the `overflow: clip` a crop adds would
|
|
4018
|
+
* otherwise clip a mis-sized enter/exit layer to nothing.
|
|
4019
|
+
*
|
|
4020
|
+
* `.crop(false)` forces the crop off (e.g. a text morph, where
|
|
4021
|
+
* `object-fit: cover` clips glyphs as the box grows); `.crop(true)` forces
|
|
4022
|
+
* it on for a non-morph the default wouldn't otherwise crop.
|
|
4006
4023
|
*/
|
|
4007
4024
|
crop(enabled?: boolean): this;
|
|
4025
|
+
/**
|
|
4026
|
+
* By default a subject's layer nests under its nearest DOM-ancestor layer
|
|
4027
|
+
* (`view-transition-group: contain`), so the ancestor's clip/transform/opacity
|
|
4028
|
+
* apply to it through the transition - mirroring how the DOM actually paints,
|
|
4029
|
+
* and letting a wrapper crop its child for the whole morph rather than only
|
|
4030
|
+
* once the live DOM takes back over. (Needs a browser that supports nested
|
|
4031
|
+
* view-transition groups; elsewhere it degrades to the flat default.)
|
|
4032
|
+
*
|
|
4033
|
+
* Call `.group(false)` to opt out: the layer stays flat and top-level, so it
|
|
4034
|
+
* animates independently and escapes an ancestor's clip - e.g. an element
|
|
4035
|
+
* that should lift out of a card and fly across, which nesting would clip.
|
|
4036
|
+
*/
|
|
4037
|
+
group(enabled?: boolean): this;
|
|
4008
4038
|
/**
|
|
4009
4039
|
* Tag this subject's generated layers with a `view-transition-class`, so
|
|
4010
4040
|
* they can be targeted from CSS - `::view-transition-group(.name)`,
|