Skip to content

PannableCanvasState

@Stable



class PannableCanvasState

Mutable pan/zoom state for a PannableCanvas - create via rememberPannableCanvasState to survive recomposition.

Constructors

PannableCanvasState

constructor()

Types

Companion

object Companion

Properties

panX

var panX: Int

panY

var panY: Int

zoom

var zoom: Float

Current zoom factor, clamped to MIN_ZOOM/MAX_ZOOM - 1f is unzoomed. Set via zoomBy, not directly, so a change always keeps zoomBy's own cursor-anchored point stationary rather than silently re-centering the view.

Functions

zoomBy

fun zoomBy(
    delta: Float, 
    cursorScreenX: Int, 
    cursorScreenY: Int
)

Adjusts zoom by delta (a scroll wheel notch, typically), keeping whatever content point currently sits under (cursorScreenX,cursorScreenY) - absolute screen coordinates, e.g. a net.kernelpanicsoft.archie.gui.modifiers.input.ScrollEvent's own mouseX/mouseY - visually stationary, the same "zoom toward the cursor" behavior a map or image viewer uses, rather than always zooming around the canvas's own top-left corner.