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-sdkInterface
On this page
import { ViewChannelOptions } from '@internote/canvas-sdk';

#Fields

glideMs
How long a toolbar-driven move takes to settle, in milliseconds.
number
Default240
lerpRequired
Returns 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) => V
readRequired
Returns the reader's own view from the environment's session state, or undefined when they have none.
(session: S | undefined) => V | undefined
writeRequired
Returns the session state with the view set, or cleared when view is undefined.
(session: S | undefined, view: V | undefined) => S
zoom
Returns 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.

Last updated