Skip to main content
Version: 4.3

PaperScrollerApi

Handle returned by usePaperScroller.

Properties

paperScroller

readonly paperScroller: PaperScroller | null;

The ui.PaperScroller view, or null until the paper/scroller has mounted.


setZoom

readonly setZoom: (value, options?) => void;

Sets the current zoom level. Accepts either an absolute number or an updater function that receives the previous zoom and returns the new value (React setState-style). The result is clamped to the minZoom / maxZoom props of the registered <PaperScroller>. No-op when no paper scroller is registered.

Parameters

ParameterTypeDescription
valuenumber | ((previous) => number)Absolute zoom or an updater (prev) => next.
options?SetZoomOptionsOptional zoom anchor (ox, oy).

Returns

void

Example

setZoom(1);                       // 100%
setZoom((prev) => prev * 1.1); // 10% in
setZoom((prev) => prev / 1.1); // 10% out

startPaperPan

readonly startPaperPan: (event) => void;

Programmatically start a pan from a pointer event. No-op when no paper scroller is registered for the current paper.

Parameters

ParameterTypeDescription
eventEvent | MouseEvent | TouchEventPointer/mouse/touch event that initiated the pan.

Returns

void


zoomToFit

readonly zoomToFit: (options?) => void;

Scales and scrolls the paper so the whole graph fits inside the visible viewport, centred and clamped to the registered <PaperScroller> zoom bounds. No-op when no paper scroller is registered.

Parameters

ParameterTypeDescription
options?ZoomToFitOptionsFit tuning: contentMargin plus scale-content options (alignment, min/max scale) forwarded to the underlying zoomToRect call. See ZoomToFitOptions.

Returns

void

Stay in the know

Be where thousands of diagramming enthusiasts meet

Star us on GitHub