← All packages

API reference

@searsuite/sear-render-coord

Conversions between document, viewport, screen, and host-view coordinates.

4 exportsderived from source

classCoordinateEnginesource ↗
class CoordinateEngine extends Plugin<SearCoreSheet, CellProperties, CoordinateState>

Sheet plugin that tracks pointer and scroll coordinates.

CoordinateEngine is the plugin-facing facade over CoordinateTransformer: it caches the latest host pointer position, reads ScrollManager state, and exposes conversions between view and world coordinates.

constructorconstructor
CoordinateEngine(scrollManager: ScrollManager, coordinates: CoordinateTransformer): CoordinateEngine

Constructs the coordinate engine and subscribes it to scroll updates.

scrollManager: ScrollManager

Scroll state manager for the current sheet.

coordinates: CoordinateTransformer

Shared coordinate transformer.

propertydepth
depth: number

Coordinate state is metadata and should render before visible plugins if queried.

propertypluginKeystatic
readonly pluginKey: PluginKey

Stable plugin key for coordinate state registration.

propertysymbolstatic
readonly symbol: symbol

DI token for resolving the coordinate engine.

methodapply
apply(state: CoordinateState, _transaction: Transaction): CoordinateState | null

Keeps coordinate state unchanged for data transactions.

ReturnsThe unchanged coordinate state.

state: CoordinateState

Current coordinate state.

_transaction: Transaction
methodgetCoordinateState
getCoordinateState(): CoordinateState

Returns a detached projection of the current input and viewport coordinates.

methodgetCurrentMouseScreen
getCurrentMouseScreen(): CoordinatePoint

Returns the latest pointer position in host-event coordinates.

ReturnsCurrent pointer coordinate as recorded from mouse events.

methodgetCurrentMouseView
getCurrentMouseView(): CoordinatePoint

Returns the latest pointer position in viewport coordinates.

methodgetCurrentMouseWorld
getCurrentMouseWorld(): CoordinatePoint

Returns the latest pointer position in scrolled sheet-world coordinates.

ReturnsCurrent pointer converted through the active scroll transform.

methodgetPluginConfig
getPluginConfig(): unknown

CoordinateEngine has no plugin-specific configuration.

methodgetVisibleScreenRect
getVisibleScreenRect(): PositionRect<unknown>

Returns the current host-view viewport rectangle.

ReturnsVisible screen-space rectangle starting at the viewport origin.

methodgetVisibleWorldRect
getVisibleWorldRect(): PositionRect<unknown>

Returns the currently visible sheet-world rectangle.

ReturnsVisible world-space viewport rectangle.

methodonMouseMove
onMouseMove(_searCore: SearCoreSheet, event: EventWithOffsetAndTarget<CellProperties>): void

Tracks the latest pointer position from sheet mouse-move events.

_searCore: SearCoreSheet
event: EventWithOffsetAndTarget<CellProperties>

Pointer event carrying host-view offsets.

methodregisterState
registerState(): { dataEngine: { enabled: boolean }; key: PluginKey; state: CoordinateState }

Registers coordinate state under the plugin key.

methodrender
render(): Node<CellProperties>[] | null

CoordinateEngine does not render scene nodes directly.

methodscreenToView
screenToView(screenX: number, screenY: number): CoordinatePoint

Converts a host-event point into an unscrolled viewport point.

screenX: number
screenY: number
methodscreenToWorld
screenToWorld(screenX: number, screenY: number): CoordinatePoint

Converts a host-event point into sheet-world coordinates.

ReturnsPoint in sheet-world coordinates.

screenX: number

Host-event x-coordinate.

screenY: number

Host-event y-coordinate.

methodworldToScreen
worldToScreen(worldX: number, worldY: number): CoordinatePoint

Converts a sheet-world point into host-view coordinates.

ReturnsPoint in host-view coordinates.

worldX: number

Sheet-world x-coordinate.

worldY: number

Sheet-world y-coordinate.

Inherited members 28

Inherited from Plugin.

interfaceCoordinatePointsource ↗
interface CoordinatePoint

Two-dimensional point in the sheet coordinate system returned by this engine.

propertyx
x: number

Horizontal coordinate.

propertyy
y: number

Vertical coordinate.

interfaceCoordinateStatesource ↗
interface CoordinateState

Local coordinate state tracked by CoordinateEngine.

propertymouseScreenX
mouseScreenX: number

Latest pointer x-position in host-event view coordinates.

propertymouseScreenY
mouseScreenY: number

Latest pointer y-position in host-event view coordinates.

propertyscrollX
scrollX: number

Latest horizontal scroll offset in world coordinates.

propertyscrollY
scrollY: number

Latest vertical scroll offset in world coordinates.

functioncreateDefaultCoordinateStatesource ↗
createDefaultCoordinateState(): CoordinateState

Creates the default coordinate plugin state.

ReturnsInitial pointer and scroll coordinates.