← All packages

@searsuite/sear-render-coord

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

classCoordinateEngine
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.

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

Constructs the coordinate engine and subscribes it to scroll updates.

scrollManager

Scroll state manager for the current sheet.

coordinates

Shared coordinate transformer.

propertydepth: number

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

propertyreadonly pluginKey: PluginKeystatic

Stable plugin key for coordinate state registration.

propertyreadonly symbol: symbolstatic

DI token for resolving the coordinate engine.

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

Keeps coordinate state unchanged for data transactions.

ReturnsThe unchanged coordinate state.

state

Current coordinate state.

methodgetCoordinateState(): CoordinateState

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

methodgetCurrentMouseScreen(): CoordinatePoint

Returns the latest pointer position in host-event coordinates.

ReturnsCurrent pointer coordinate as recorded from mouse events.

methodgetCurrentMouseView(): CoordinatePoint

Returns the latest pointer position in viewport coordinates.

methodgetCurrentMouseWorld(): CoordinatePoint

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

ReturnsCurrent pointer converted through the active scroll transform.

methodgetPluginConfig(): unknown

CoordinateEngine has no plugin-specific configuration.

methodgetVisibleScreenRect(): PositionRect<unknown>

Returns the current host-view viewport rectangle.

ReturnsVisible screen-space rectangle starting at the viewport origin.

methodgetVisibleWorldRect(): PositionRect<unknown>

Returns the currently visible sheet-world rectangle.

ReturnsVisible world-space viewport rectangle.

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

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

event

Pointer event carrying host-view offsets.

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

Registers coordinate state under the plugin key.

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

CoordinateEngine does not render scene nodes directly.

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

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

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

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

ReturnsPoint in sheet-world coordinates.

screenX

Host-event x-coordinate.

screenY

Host-event y-coordinate.

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

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

ReturnsPoint in host-view coordinates.

worldX

Sheet-world x-coordinate.

worldY

Sheet-world y-coordinate.

Inherited members 27

Inherited from Plugin.

interfaceCoordinatePoint

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

propertyx: number

Horizontal coordinate.

propertyy: number

Vertical coordinate.

interfaceCoordinateState

Local coordinate state tracked by CoordinateEngine.

propertymouseScreenX: number

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

propertymouseScreenY: number

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

propertyscrollX: number

Latest horizontal scroll offset in world coordinates.

propertyscrollY: number

Latest vertical scroll offset in world coordinates.

functioncreateDefaultCoordinateState
createDefaultCoordinateState(): CoordinateState

Creates the default coordinate plugin state.

ReturnsInitial pointer and scroll coordinates.