feat(tasks): 自动适配改为滑行——展开后仍保持自适应居中,且不再瞬跳

维护者第三轮反馈:在 fit(自适应)档位下展开后,画面也应回到自适应位置,
避免节点溢出面板 / 不在中间。上一版让折叠「接管视图」正是拿这个换的平滑。

收口方式:把视图变换本身也做成补间。

- 新增 tasks-view-glide.ts:把 fit 的算术抽成纯函数 fitTransform(用 CONTENT 盒而
  非含 padding 的整张画布定缩放、双轴居中、容器未测量时返回 undefined),外加
  lerpTransform 与 GLIDE_MS。这两块在 jsdom 里可达,因此有了单测(居中、上下限、
  未测量、滑行中点)。
- TasksGraph:fit 拆成 fitTarget(算术)+ applyFit(animate)。布局变化且视图仍属自动
  适配时→**滑行**(rAF 220ms,与卡片补间同一条缓动);切会话→直接落位(内容整体
  换掉);⌂ / 背景双击→滑回。任何读者手势(pointerdown / 滚轮 / 缩放按钮)立刻取消
  滑行,并照旧把视图标记为「已接管」。
- 折叠不再接管视图(去掉上一版的 markTouched 包装):展开即滑到新取景,画面保持
  居中且内容完整。

测试:tests/tasks-view-glide.spec.ts(4 条:居中与缩放上限/下限、未测量返回 undefined、
滑行插值)与 tests/tasks-motion.spec.ts 第 4 条改写(布局变化必须滑行、切会话必须落位、
手势必须能取消)。全套 2252 passed / 17 skipped(194 文件)、tsc 与 eslint 零告警、
构建通过;新构建已装进 sidebar-test,:3080 挂载正常(0 pageerror)。
This commit is contained in:
Menghuan1918 committed 2026-10-11 23:35:52 +08:00
1 parent e6f9eda60f
commit d035836a51
6 files changed
+254 -73

No files matched your search

+1 -1
View File
@@ -13,7 +13,7 @@
- 📊 **节点详情多两项事实**:新增 **Token 用量**(宿主 `tokenUsage` projection 的四个互斥桶求和,悬停给出未缓存输入 / 缓存读取 / 缓存写入 / 输出明细)与 **耗时**(宿主 `subagentTiming`:已结算回合 + 正在跑的那一轮,按页面轮询刷新)。两项都按宿主投影的**存在性**渲染——没有测量就不显示这一行,绝不打印一个说不清的 0;`SidebarProjectionSnapshot.values` 的镜像类型同步补上这两个键。
- 🪟 **「查看转录」改为在原生右侧栏打开**(这是宿主自带能力):`dsh-resource://subagentchat/session/<childId>?parent=&mode=` + `ctx.sidebarRight.openResource(..., { kind: 'subagentchat', preferNewPane: true })`——与宿主自己的子代理列表(点行 = 主窗、点 chevron = 侧栏)同一套 tab 类型,主列保持不动;右侧新增小下拉按钮,菜单里可**在主窗中打开**(走原有的 `uiWorkspace.openSession` + 页签重挂)。宿主没有该 tab 类型 / 没有右栏 / 没有挂载会话时逐项降级回主窗并保持单按钮。
- ✨ **动效:画布在自己的坐标系里补间**(`tasks-layout-tween.ts`)。卡片层带着 fit 的 `transform: scale(k)`,所以任何「量 rect、播 transform」的 FLIP 库在这里都是错的——`@formkit/auto-animate` 更会把离场卡片钉上由 rect 换算的绝对 `left/top`(缩放层里根本表达不出来 → 跳位)。改为**直接补间布局坐标**(每张卡的 `x`/`y`/高度):`left`/`top` 就是画布自己的单位,缩放对它和对终点位置一样生效;而连线路径与相位框都是「盒子的纯函数」,于是**跟着卡片逐帧走**,不再在卡片还在飞的时候先瞬移到终点。入场另有 CSS 关键帧(300ms:上浮 + 0.88→1 缩放 + 淡入,带轻微过冲),并按节点顺序**错峰 26ms**(一次展开多张时是瀑布而不是一下全冒),`backwards` 填充让等待中的卡片先隐形而不是先冒再动。
- 🧭 **读者一碰折叠,视图就归他**:点聚合 / 点卡片 chevron / 控制条折叠开关都会把视图标记为「已接管」(与拖拽、缩放同一条规则),此后画布不再随布局变化自动重框——折叠时不会再把整棵树从读者眼皮底下抽走;⌂ 按钮交还自动适配。切会话时重置并重新适配(新的树 = 新的画布),顺带修掉「拖过一次之后换会话就不再适配」的旧账。
- 🧭 **自动适配改成「滑过去」而不是「跳过去」**:布局一变,视图变换(平移 + 缩放)与卡片一起补间 220ms,于是**展开后画面仍然是自适应的居中位置**(不会让节点溢出面板/偏到一角),同时也没有原来那种瞬跳。规则不变:读者拖过或缩放过就不再自动重框(那一刻视图归他),⌂ 按钮随时交还自动适配;切会话重置并重新适配(新的树 = 新的画布),顺带修掉「拖过一次之后换会话就不再适配」的旧账。
- 🪶 **FLIP 库只留给流式布局**:树模式行与后台任务行的离场是「原地淡出 + 兄弟滑位」,那正是 FLIP 的语义且不受缩放影响;画布则明确排除(`tests/tasks-motion.spec.ts` 钉死:画布不得 import 它、树与抽屉必须有)。
- 🧪 测试:新增 `tests/session-metrics.spec.ts`(5 条:四桶求和、空投影、运行中耗时按渲染时钟、0 不算工作、时钟回拨不显示负数)与 `tests/activity-icons.spec.ts`(3 条:13 个类别全覆盖、读 / 命令 / 搜索 / 网页互不同型、`undefined` 走思考图标);`tests/tasks-page.spec.tsx` 补 6 条(原生状态取代状态词、无数据回退、根卡真实状态、浮窗活动块位置、一次只开一组 + 判据极性的判别性用例、展开后成员仍可手工折回、Token / 耗时两行、侧栏打开地址 + 下拉在主窗打开 + 无宿主能力时单按钮、模式 chip 在徽标行);`tests/tasks-graph-layout.spec.ts` 的高度 / 行距断言跟随新的卡片预算。[设计文档](docs/plans/2026-10-11-tasks-status-and-group-fold.md)。
@@ -137,8 +137,11 @@ state === 'running' → liveActivityLabel(summary) // 宿主 mess
目标盒子渲染(否则会有「先消失一帧再出现」的闪烁,首版实测就踩到了)。
- **入场用 CSS 关键帧**:300ms 上浮 + `scale(0.88→1)` + 淡入(轻微过冲),按节点页序**错峰 26ms**,`fill-mode: backwards`
让等待中的卡片先隐形。`prefers-reduced-motion` 下补间与入场都关闭。
- **读者碰折叠即接管视图**:`markTouched` 挂在三个折叠入口上(聚合卡、卡片 chevron、控制条开关),此后不再随布局自动重框;
切会话重置并重新适配(顺带修掉「拖过一次后换会话不再适配」)。
- **自动适配改为滑行**(维护者第三轮反馈:「最开始在 fit 档位,展开后也要是自适应的位置,避免节点溢出屏幕 / 不在中间」)。
上一版让折叠「接管视图」,代价正是这一条。收口方式:**视图变换本身也补间**(`tasks-view-glide.ts`:把 fit 的算术抽成
纯函数并单测,`applyFit(animate)` 用 rAF 把 `x/y/k` 从当前位置滑到新目标,220ms 与卡片同一条缓动)。于是
「保持自适应」与「不许瞬跳」不再二选一:布局一变就滑到新取景,展开后画面仍是居中、内容仍完整;只有读者拖过 / 缩放过
(`touchedRef`)才不再自动重框,任何读者手势(pointerdown / 滚轮 / 缩放按钮)都会立刻取消滑行。切会话仍旧直接落位(内容整体换掉)。
- **FLIP 库保留在流式布局**(树视图、任务抽屉);`tests/tasks-motion.spec.ts` 把「画布不得 import 它」写进守护,
`tests/tasks-layout-tween.spec.tsx` 钉住插值 / 缓动 / 中途位置 / 画布尺寸不中途变化 / 入场盒子不缺席。
2. **真机只跑通到「插件挂载 + 零 pageerror」**:新构建已装进 `sidebar-test` profile 并在 http://127.0.0.1:3080 提供服务(`[data-dsh-better-sidebar]` 挂载、`/sidebar/api/*` 200、无 pageerror / console error)。但**动效与观感的逐帧复核没做成**:宿主右栏在无头上下文里以 `transform` 平移到视口外,我的合成点击无法稳定地把任务页调出来(多次尝试后放弃)。这一条由维护者自己在实例上看。
+91 -62
View File
@@ -41,6 +41,15 @@ import {
type GraphBox,
} from './tasks-graph-layout.ts'
import { useTweenedLayout } from './tasks-layout-tween.ts'
import { easeOut as glideEase } from './tasks-layout-tween.ts'
import { fitTransform, GLIDE_MS, lerpTransform, type ViewTransform } from './tasks-view-glide.ts'
/** Whether the reader asked the platform for less motion. */
function prefersReducedMotion(): boolean {
return typeof window !== 'undefined'
&& typeof window.matchMedia === 'function'
&& window.matchMedia('(prefers-reduced-motion: reduce)').matches
}
import {
activityLine, agentChip, agentMeta, foldErrorTally, foldPreviews, FoldGlyph, foldTally,
TaskLine, WorkflowGlyph, workflowMeta,
@@ -223,35 +232,69 @@ export function TasksGraph(props: TasksGraphProps): ReactNode {
const edges = useMemo(() => tasksEdges(nodes), [nodes])
const nodeById = useMemo(() => new Map(nodes.map(node => [node.id, node])), [nodes])
/** A running view glide (see fit): cancelled by any reader gesture. */
const glideRef = useRef(0)
/** Stop a glide where it is (the reader took the wheel). */
const stopGlide = useCallback((): void => {
if (glideRef.current !== 0) {
cancelAnimationFrame(glideRef.current)
glideRef.current = 0
}
}, [])
/**
* Center the canvas and scale it to fill. The fit measures the CONTENT box
* (the layout's padding is breathing room, not content): centering the padded
* box leaves the graph visibly off-center in a narrow panel, which is exactly
* how "the graph looks small and sits in a corner" happens.
* The frame the auto-fit wants right now, or undefined before the container
* has been measured (the sidebar mounts hidden at zero size). The arithmetic
* lives in tasks-view-glide.ts, where a test can reach it.
*/
const fit = useCallback((): void => {
const fitTarget = useCallback((): ViewTransform | undefined => {
const container = containerRef.current
if (container === null) return
const cw = container.clientWidth
const ch = container.clientHeight
if (cw === 0 || ch === 0) return
const contentW = Math.max(GRAPH_NODE_W, layout.width - GRAPH_PAD * 2)
const contentH = Math.max(GRAPH_NODE_H, layout.height - GRAPH_PAD * 2)
const k = Math.max(
GRAPH_FIT_MIN_SCALE,
Math.min(
(cw - FIT_MARGIN * 2) / contentW,
(ch - FIT_MARGIN * 2) / contentH,
FIT_MAX_SCALE,
),
)
setTf({
x: (cw - contentW * k) / 2 - GRAPH_PAD * k,
y: Math.max(FIT_MARGIN / 2, (ch - contentH * k) / 2) - GRAPH_PAD * k,
k,
if (container === null) return undefined
return fitTransform({
containerW: container.clientWidth,
containerH: container.clientHeight,
layoutW: layout.width,
layoutH: layout.height,
pad: GRAPH_PAD,
minContentW: GRAPH_NODE_W,
minContentH: GRAPH_NODE_H,
margin: FIT_MARGIN,
minScale: GRAPH_FIT_MIN_SCALE,
maxScale: FIT_MAX_SCALE,
})
}, [layout.width, layout.height])
/**
* Put the frame where the fit wants it, either at once (a resize while the
* reader drags the panel edge, a fresh session) or as a GLIDE — the layout
* tween moves the cards, and the frame has to travel with them instead of
* jumping to the new framing a frame later. That glide is what makes "stay
* auto-fitted" and "never yank the view" the same behavior.
*
* @param animate - glide instead of snapping.
*/
const applyFit = useCallback((animate: boolean): void => {
const target = fitTarget()
if (target === undefined) return
stopGlide()
if (!animate || prefersReducedMotion()) {
setTf(target)
return
}
const from = tfRef.current
const started = performance.now()
const step = (): void => {
const progress = glideEase((performance.now() - started) / GLIDE_MS)
setTf(lerpTransform(from, target, progress))
glideRef.current = progress < 1 ? requestAnimationFrame(step) : 0
}
glideRef.current = requestAnimationFrame(step)
}, [fitTarget, stopGlide])
/** The reader's own re-fit (the ⌂ button and a background double-click). */
const fit = useCallback((): void => { applyFit(true) }, [applyFit])
/**
* Keep the canvas reachable: a pan or a zoom-out may never push the whole
* graph off screen (the classic "I dragged it away and cannot find it").
@@ -281,22 +324,24 @@ export function TasksGraph(props: TasksGraphProps): ReactNode {
fit()
}, [fit])
/** The newest `fit`, so the effects below can depend on WHAT changed. */
const fitRef = useRef(fit)
fitRef.current = fit
/** The newest `applyFit`, so the effects below can depend on WHAT changed. */
const fitRef = useRef(applyFit)
fitRef.current = applyFit
// A different tree is a different canvas: re-fit AND hand the view back to the
// auto-fit, whatever the reader did to the previous one.
// auto-fit, whatever the reader did to the previous one. Snapped, because the
// content changes wholesale.
useEffect(() => {
touchedRef.current = false
fitRef.current()
fitRef.current(false)
}, [rootId])
// Auto-fit on layout growth — but never over a view the reader has taken over
// (a pan, a zoom, or a fold: see markTouched). The container's own resize
// path below fits under the same rule.
// Layout growth while the reader has left the view alone: glide to the new
// framing, so expanding a group KEEPS the graph centred and inside the panel
// without the frame jumping out from under the cards travelling to it. A
// reader who panned or zoomed owns the view, and nothing moves it.
useEffect(() => {
if (!touchedRef.current) fitRef.current()
if (!touchedRef.current) fitRef.current(true)
}, [layout.width, layout.height])
useEffect(() => {
@@ -328,6 +373,7 @@ export function TasksGraph(props: TasksGraphProps): ReactNode {
const next = Math.min(ZOOM_MAX, Math.max(ZOOM_MIN, k * Math.exp(-event.deltaY * unit * 0.0014)))
if (next === k) return
touchedRef.current = true
stopGlide()
setTf(clampTf({
x: mx - (mx - x) * (next / k),
y: my - (my - y) * (next / k),
@@ -336,7 +382,7 @@ export function TasksGraph(props: TasksGraphProps): ReactNode {
}
container.addEventListener('wheel', onWheel, { passive: false })
return () => { container.removeEventListener('wheel', onWheel) }
}, [clampTf])
}, [clampTf, stopGlide])
const zoomBy = useCallback((factor: number): void => {
const container = containerRef.current
@@ -344,10 +390,11 @@ export function TasksGraph(props: TasksGraphProps): ReactNode {
const next = Math.min(ZOOM_MAX, Math.max(ZOOM_MIN, k * factor))
if (next === k || container === null) return
touchedRef.current = true
stopGlide()
const mx = container.clientWidth / 2
const my = container.clientHeight / 2
setTf(clampTf({ x: mx - (mx - x) * (next / k), y: my - (my - y) * (next / k), k: next }))
}, [clampTf])
}, [clampTf, stopGlide])
/**
* Drag-pan. The gesture only ever starts on the BACKGROUND: a pointerdown
@@ -370,6 +417,7 @@ export function TasksGraph(props: TasksGraphProps): ReactNode {
const onPointerDown = useCallback((event: ReactPointerEvent<HTMLDivElement>): void => {
if (event.button !== 0) return
stopGlide()
const target = event.target as HTMLElement
if (target.closest('[data-graph-node]') !== null) return
if (target.closest('[data-graph-controls]') !== null) return
@@ -395,36 +443,17 @@ export function TasksGraph(props: TasksGraphProps): ReactNode {
window.addEventListener('pointermove', onMove)
window.addEventListener('pointerup', onUp)
window.addEventListener('pointercancel', onUp)
}, [clampTf])
}, [clampTf, stopGlide])
/** Suppress node clicks that ended a drag gesture. */
const clickAllowed = useCallback((): boolean => travelRef.current <= CLICK_TOLERANCE_PX, [])
/**
* The reader driving the FOLD state takes the view over, exactly like a pan
* or a zoom does: from then on the canvas stops re-framing itself when the
* layout changes, so folding a group never yanks the tree out from under the
* cards the reader is watching. The ⌂ button hands the view back.
/*
* Folding does NOT claim the view. The frame stays auto-fitted for as long as
* the reader has not panned or zoomed, and the fit GLIDES (applyFit), so a
* group that expands larger than the panel stays centred and inside it
* without the jump that claiming the view used to trade for.
*/
const markTouched = useCallback((): void => { touchedRef.current = true }, [])
/** The aggregate's click: reveal its group, with the view under the reader. */
const expandGroupTouched = useCallback((node: TasksFoldNode): void => {
markTouched()
onExpandGroup(node)
}, [markTouched, onExpandGroup])
/** The card's own chevron: fold that node, with the view under the reader. */
const foldNodeTouched = useCallback((node: TasksAgentNode): void => {
markTouched()
onFoldNode?.(node)
}, [markTouched, onFoldNode])
/** The cluster's page-level switch: the same claim on the view. */
const toggleFoldTouched = useCallback((): void => {
markTouched()
onToggleFold()
}, [markTouched, onToggleFold])
// Phase frames: group each run's members by phase and box them.
const phaseFrames = useMemo((): PhaseFrame[] => {
@@ -561,16 +590,16 @@ export function TasksGraph(props: TasksGraphProps): ReactNode {
*/
animationDelay: `${Math.min(index, 9) * 26}ms`,
}
if (node.kind === 'fold') return renderFoldNode(node, style, expandGroupTouched, clickAllowed)
if (node.kind === 'fold') return renderFoldNode(node, style, onExpandGroup, clickAllowed)
if (node.kind === 'workflow') {
return renderWorkflowNode(node, style, onWorkflowInfo, clickAllowed)
}
return renderAgentNode(node, style, onNodeInfo, onOpenTask, clickAllowed, foldNodeTouched)
return renderAgentNode(node, style, onNodeInfo, onOpenTask, clickAllowed, onFoldNode)
})}
</div>
<div className={css.controls} data-graph-controls>
<ViewModeToggle mode={mode} onModeChange={onModeChange} />
<FoldToggleButton folded={folded} onToggleFold={toggleFoldTouched} />
<FoldToggleButton folded={folded} onToggleFold={onToggleFold} />
<Button
variant="ghost"
size="sm"
+81
View File
@@ -0,0 +1,81 @@
/**
* The Tasks canvas's VIEW transforms: where the auto-fit puts the frame, and
* how the frame travels when that answer changes.
*
* Kept pure and separate because the graph itself cannot be measured in a test
* (jsdom reports every container as 0×0): the centring rule and the glide's
* interpolation are the two things worth pinning, and both are just arithmetic
* over numbers the caller already has.
*
* The rule the fit follows: scale so the CONTENT box (never the padded canvas)
* fills the container, never below the readability floor and never above the
* cap, then centre it on both axes. Centring the padded box is what makes a
* narrow panel look off-centre, so the padding is subtracted before the scale
* is chosen and folded back into the offset.
*/
/** One canvas transform: translation in px plus the scale. */
export interface ViewTransform {
x: number
y: number
k: number
}
/** How long the frame takes to glide to a new auto-fit (ms). */
export const GLIDE_MS = 220
/** The inputs of the auto-fit (all px, pre-scale). */
export interface FitInput {
/** The canvas viewport. */
containerW: number
containerH: number
/** The layout's extent, padding included. */
layoutW: number
layoutH: number
/** The layout's own padding (breathing room, not content). */
pad: number
/** The smallest content box the fit will measure (one card). */
minContentW: number
minContentH: number
/** Breathing room the fit leaves around the content, per axis. */
margin: number
/** The readability floor and the ballooning cap. */
minScale: number
maxScale: number
}
/**
* The transform that fits and centres the content, or undefined when the
* container has no size yet (the sidebar mounts hidden at zero size, so a fit
* before its first measure must do nothing rather than divide by zero).
*/
export function fitTransform(input: FitInput): ViewTransform | undefined {
const { containerW, containerH } = input
if (containerW === 0 || containerH === 0) return undefined
const contentW = Math.max(input.minContentW, input.layoutW - input.pad * 2)
const contentH = Math.max(input.minContentH, input.layoutH - input.pad * 2)
const k = Math.max(
input.minScale,
Math.min(
(containerW - input.margin * 2) / contentW,
(containerH - input.margin * 2) / contentH,
input.maxScale,
),
)
return {
x: (containerW - contentW * k) / 2 - input.pad * k,
y: Math.max(input.margin / 2, (containerH - contentH * k) / 2) - input.pad * k,
k,
}
}
/**
* One frame of a glide between two transforms.
*
* @param from - where the frame is.
* @param to - where it is going.
* @param progress - 0…1, already eased by the caller.
*/
export function lerpTransform(from: ViewTransform, to: ViewTransform, progress: number): ViewTransform {
const mix = (a: number, b: number): number => a + (b - a) * progress
return { x: mix(from.x, to.x), y: mix(from.y, to.y), k: mix(from.k, to.k) }
}
+12 -8
View File
@@ -71,14 +71,18 @@ describe('Tasks page motion', () => {
expect(source('src/client/TasksGraph.tsx')).toContain('animationDelay')
})
it('stops the auto-fit once the reader drives the fold state', () => {
const graph = source('src/client/TasksGraph.tsx')
// Pan/zoom already claim the view; folding claims it too, so the canvas
// never re-frames itself under the cards the reader is watching.
expect(graph).toContain('markTouched')
expect(graph).toContain('expandGroupTouched')
expect(graph).toContain('foldNodeTouched')
expect(graph).toContain('toggleFoldTouched')
it('keeps the frame auto-fitted across a fold, by GLIDING rather than jumping', () => {
const graph = code('src/client/TasksGraph.tsx')
// Folding must not claim the view: while the reader has not taken over, a
// layout change glides the frame to the new fit, so an expanded group stays
// centred and inside the panel without yanking the view.
expect(graph).not.toContain('markTouched')
// The untouched-view path GLIDES to the new framing; a fresh session snaps
// (the content changes wholesale), and the reader's own gestures cancel a
// glide in flight.
expect(graph).toContain('if (!touchedRef.current) fitRef.current(true)')
expect(graph).toContain('fitRef.current(false)')
expect(graph).toContain('stopGlide()')
})
it('parks the motion host behind a WAAPI guard so tests and old hosts stay inert', () => {
+64
View File
@@ -0,0 +1,64 @@
/**
* Unit tests for the canvas's auto-fit arithmetic and its glide — the two
* pieces of the view transform that a jsdom test can reach (a container there
* measures 0×0, so the graph's own `fit` cannot be exercised).
*/
import { describe, expect, it } from 'vitest'
import {
fitTransform, lerpTransform, type FitInput,
} from '../src/client/tasks-view-glide.ts'
/** The graph's own fit inputs, centred on a small tree in a narrow panel. */
function input(over: Partial<FitInput> = {}): FitInput {
return {
containerW: 360,
containerH: 600,
layoutW: 430,
layoutH: 260,
pad: 16,
minContentW: 190,
minContentH: 87,
margin: 24,
minScale: 0.78,
maxScale: 1.3,
...over,
}
}
describe('fitTransform', () => {
it('scales to the CONTENT box and centres it on both axes', () => {
const transform = fitTransform(input())
expect(transform).toBeDefined()
const { x, y, k } = transform!
// Content = 430-32 × 260-32 = 398 × 228; the panel is 360 wide, so the
// WIDTH is what limits the scale (the height would allow 2.4×).
expect(k).toBeCloseTo((360 - 48) / 398, 6)
expect(x).toBeCloseTo((360 - 398 * k) / 2 - 16 * k, 6)
expect(y).toBeCloseTo(Math.max(12, (600 - 228 * k) / 2) - 16 * k, 6)
// …and the content really is inside the panel and centred: equal margins.
const leftEdge = x + 16 * k
const rightEdge = x + 16 * k + 398 * k
expect(360 - rightEdge).toBeCloseTo(leftEdge, 6)
})
it('never balloons a small tree past the cap, and never shrinks below the floor', () => {
expect(fitTransform(input({ layoutW: 200, layoutH: 100 }))?.k).toBe(1.3)
expect(fitTransform(input({ layoutW: 4_000, layoutH: 4_000 }))?.k).toBe(0.78)
})
it('answers nothing before the container has been measured', () => {
// The sidebar mounts hidden at zero size: a fit then must not divide by it.
expect(fitTransform(input({ containerW: 0 }))).toBeUndefined()
expect(fitTransform(input({ containerH: 0 }))).toBeUndefined()
})
})
describe('lerpTransform', () => {
it('walks the frame between two transforms', () => {
const from = { x: 0, y: 0, k: 1 }
const to = { x: 100, y: -40, k: 0.5 }
expect(lerpTransform(from, to, 0)).toEqual(from)
expect(lerpTransform(from, to, 1)).toEqual(to)
expect(lerpTransform(from, to, 0.5)).toEqual({ x: 50, y: -20, k: 0.75 })
})
})