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​
| Parameter | Type | Description |
|---|---|---|
value | number | ((previous) => number) | Absolute zoom or an updater (prev) => next. |
options? | SetZoomOptions | Optional 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​
| Parameter | Type | Description |
|---|---|---|
event | Event | MouseEvent | TouchEvent | Pointer/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​
| Parameter | Type | Description |
|---|---|---|
options? | ZoomToFitOptions | Fit tuning: contentMargin plus scale-content options (alignment, min/max scale) forwarded to the underlying zoomToRect call. See ZoomToFitOptions. |
Returns​
void