ViewChannelOptions
What an environment supplies to createViewChannel: its view's shape, where it lives in the session state, and how two views blend.
@internote/canvas-sdkimport { ViewChannelOptions } from '@internote/canvas-sdk';#Fields
glideMsHow long a toolbar-driven move takes to settle, in milliseconds.
numberDefault
240lerpReturns the view
t of the way between two views. Called every frame of a glide, so it is also where an environment says what "between" means for its own geometry: the short way round a sphere, a zoom that moves in levels.(from: V, to: V, t: number) => VreadReturns the reader's own view from the environment's session state, or
undefined when they have none.(session: S | undefined) => V | undefinedwriteReturns the session state with the view set, or cleared when
view is undefined.(session: S | undefined, view: V | undefined) => SzoomReturns the view one toolbar zoom step in (
1) or out (-1) from a view, or null where that step would pass the environment's limit. A button press has no cursor to aim at, so a step is about the view's centre. An environment that supplies this gets Zoom in and Zoom out beside Reset view.(view: V, direction: 1 | -1, where: ViewHolder) => V | null#Example
const plotView = createViewChannel<Window, PlotSession>({
read: (session) => session?.view,
write: (session, view) => ({ ...(session ?? initialSession()), view }),
lerp: (from, to, t) => ({ x: lerpInterval(from.x, to.x, t), y: lerpInterval(from.y, to.y, t) }),
});Declared in packages/canvas-sdk/src/view/index.ts:70.