PanZoomState

class PanZoomState(initialCenter: DoubleOffset? = null, initialZoom: Double = 1.0, val minimumZoom: Double = 1.0, val maximumZoom: Double = 64.0)(source)

Caller-owned mutable transform shared by one viewport and independent navigation controls.

Center coordinates use the content coordinate space, and zoom is a multiplier over the viewport's PanZoomFit scale. One live retained observer may own viewport geometry, while additional observers may read transform changes without publishing geometry. Reads, writes, observation, geometry publication, and observer release are confined to the construction execution owner. Observer callbacks may read state and release observers, but synchronous state writes are rejected so every observer sees a publication that still matches PanZoomState.metrics. If an observer fails, the committed metrics remain current, every other still-live observer is attempted, and the first failure escapes with later failures suppressed. The state owns no retained nodes or rendering resources.

Parameters

initialCenter

requested initial content center, or null to center the first published content bounds.

initialZoom

initial zoom multiplier within PanZoomState.minimumZoom and PanZoomState.maximumZoom.

Throws

when zoom limits or initial values are invalid.

Constructors

Link copied to clipboard
constructor(initialCenter: DoubleOffset? = null, initialZoom: Double = 1.0, minimumZoom: Double = 1.0, maximumZoom: Double = 64.0)

Properties

Link copied to clipboard

positive finite maximum zoom multiplier.

Link copied to clipboard

Current immutable transform and geometry snapshot.

Link copied to clipboard

positive finite minimum zoom multiplier.

Functions

Link copied to clipboard

Centers the viewport on a content coordinate.

Link copied to clipboard

Converts a content coordinate to the current viewport-local coordinate space.

Link copied to clipboard

Converts a viewport-local coordinate to the current content coordinate space.

Link copied to clipboard

Registers one privileged owner-confined observer without immediately invoking it.

Link copied to clipboard

Moves the viewport center by a displacement in content units.

Link copied to clipboard

Restores minimum zoom and centers the current content bounds.

Link copied to clipboard
fun updateGeometry(contentBounds: LongRect, viewportSize: IntSize, fit: PanZoomFit, origin: PanZoomStateObserver)

Publishes positive content and viewport geometry from one privileged retained viewport.

Link copied to clipboard
fun zoomBy(factor: Double, anchor: DoubleOffset? = null): Double

Multiplies zoom and optionally preserves one viewport-local anchor.

Link copied to clipboard
fun zoomTo(zoom: Double, anchor: DoubleOffset? = null): Double

Sets zoom and optionally preserves one viewport-local anchor.