← All packages

API reference

@searsuite/sear-render-scroll

Logical scrolling, axis locking, boundary feedback, and host scroller adapters.

18 exportsderived from source

classHeadlessScrollersource ↗
class HeadlessScroller extends Scroller

Scroller adapter for hosts that have no native scroll surface.

constructorconstructor
HeadlessScroller(): HeadlessScroller

Constructs a scroller adapter.

propertysymbolstatic
readonly symbol: symbol

DI token for resolving HeadlessScroller.

methodgetPublisher
getPublisher(): ScrollPublisher

Returns the publisher.

Inherited members 2

Inherited from Scroller.

classRubberBandConfigErrorsource ↗
class RubberBandConfigError extends SearError

Stable public error raised for invalid rubber-band physics configuration.

constructorconstructor
RubberBandConfigError(message: string, details?: SearErrorDetails, options?: ErrorOptions): RubberBandConfigError

Creates a SearError instance.

message: string
details: SearErrorDetails
options: ErrorOptions
propertycode
readonly code: "SEAR_SCROLL_INVALID_RUBBER_BAND_CONFIG"

Stable machine-readable identifier for this error category.

Inherited members 9

Inherited from SearError.

classRubberBandControllersource ↗
class RubberBandController

Platform-neutral Safari-style overscroll physics.

Logical positions never leave their boundaries. Raw excess input is mapped to a visual displacement with WebKit's viewport-relative resistance curve, then returned by a damped harmonic spring once boundary input settles.

constructorconstructor
RubberBandController(platform: Platform, publishOffset: (offset: RubberBandOffset): void): RubberBandController

Creates one controller and publishes every visual displacement change.

platform: Platform
publishOffset: (offset: RubberBandOffset): void
methodconfigure
configure(config: Partial<RubberBandConfig>): void

Applies validated host overrides and resets immediately when disabled.

config: Partial<RubberBandConfig>
methodconsume
consume(input: RubberBandInput): RubberBandOffset

Consumes one wheel or touch sample and returns a clamped logical position. Reversing direction first consumes existing excess before logical scrolling resumes.

input: RubberBandInput
methodgetOffset
getOffset(): RubberBandOffset

Returns a copy of the current transient visual displacement.

methodrelease
release(delay?: number, preserveVelocity?: boolean): void

Starts the boundary return after the configured input-settle delay.

delay: number
preserveVelocity: boolean
methodreset
reset(): void

Cancels pending work and restores the exact zero-displacement state.

classScrollAxisLocksource ↗
class ScrollAxisLock

Locks a continuous input gesture to its first dominant axis.

constructorconstructor
ScrollAxisLock(): ScrollAxisLock
methodconfigure
configure(config: Partial<ScrollAxisLockConfig>): void

Applies validated host overrides and resets an in-progress gesture.

config: Partial<ScrollAxisLockConfig>
methodconsume
consume(x: number, y: number): { x: number; y: number }

Filters one two-dimensional input sample through the active direction lock.

x: number
y: number
methodgetAxis
getAxis(): ScrollAxis | null

Returns the currently selected axis, or null before activation.

methodgetWheelEndDelay
getWheelEndDelay(): number

Returns the configured wheel gesture-end delay.

methodreset
reset(): void

Ends the current gesture and clears uncommitted sub-threshold input.

classScrollAxisLockConfigErrorsource ↗
class ScrollAxisLockConfigError extends SearError

Stable public error raised for invalid scroll-axis lock configuration.

constructorconstructor
ScrollAxisLockConfigError(message: string, details?: SearErrorDetails, options?: ErrorOptions): ScrollAxisLockConfigError

Creates a SearError instance.

message: string
details: SearErrorDetails
options: ErrorOptions
propertycode
readonly code: "SEAR_SCROLL_INVALID_AXIS_LOCK_CONFIG"

Stable machine-readable identifier for this error category.

Inherited members 9

Inherited from SearError.

classScrollersource ↗
class Scroller

Base class for host scroll adapters.

Concrete scrollers own platform scroll surfaces while ScrollManager owns the platform-neutral viewport state.

constructorconstructor
Scroller(): Scroller

Constructs a scroller adapter.

propertyconfigEngine
readonly configEngine: ConfigEngine

Configuration engine available to concrete scroller adapters.

propertyContainerSymbolstatic
readonly ContainerSymbol: symbol

DI token used by hosts that provide a scroller container.

propertysymbolstatic
readonly symbol: symbol

DI token for resolving the active scroller adapter.

classScrollerFactorysource ↗
class ScrollerFactory

Factory registry for host scroller adapters.

constructorconstructor
ScrollerFactory(): ScrollerFactory
methodcreateScrollerstatic
createScroller(type: string | symbol, args: unknown): Scroller

Creates a scroller for a registered type.

ReturnsNew scroller adapter.

type: string | symbol

Scroller type key.

args: unknown

Adapter-specific construction input.

methodregisterScrollerstatic
registerScroller(type: string | symbol, scrollerCreator: (args: unknown): Scroller): void

Registers a scroller creator.

type: string | symbol

Scroller type key.

scrollerCreator: (args: unknown): Scroller

Factory invoked by createScroller().

classScrollManagersource ↗
class ScrollManager

Owns viewport scroll state and fans updates out to render subscribers.

constructorconstructor
ScrollManager(width: number, height: number): ScrollManager

Creates a scroll manager for a viewport of the given dimensions.

width: number
height: number
propertysymbolstatic
readonly symbol: symbol

DI token for resolving the scroll manager.

methodaddPublisher
addPublisher(publisher: ScrollPublisher): (): void

Connects a scroll-event source and returns an idempotent disposer.

publisher: ScrollPublisher
methodapplyInputScroll
applyInputScroll(state: ScrollManagerState): void

Applies platform scroll data within the owning editor's command.

state: ScrollManagerState
methoddestroy
destroy(ownerToken?: object): void

Disconnects publishers and subscribers owned by this manager.

ownerToken: object
methodenforceCommandBoundary
enforceCommandBoundary(isExecuting: (): boolean): void

Closes direct viewport writes after the owning editor finishes restoration.

isExecuting: (): boolean
methodenforceTeardownBoundary
enforceTeardownBoundary(ownerToken: object): void

Reserves publisher cleanup for the owning editor.

ownerToken: object
methodgetContentBoundary
getContentBoundary(): [number, number]

Returns the maximum logical scroll positions for platform adapters.

methodgetPositionRect
getPositionRect(): PositionRect<templateLiteral>

Returns the viewport rectangle as (0, 0, width, height).

The scroll position is NOT included in the returned rect. Consumers that need the world-coordinate viewport should construct their own rect using scrollState.x/y (available via getState()).

Historically this method returned (state.x, state.y, width, height), but since ScrollManager.update() now clamps state.x/y in-place, including them caused double-offset bugs in render strategies that already add scrollState.x/y to compute world-coordinate query rects.

methodgetPreviousState
getPreviousState(): ScrollManagerState | null

Returns the previous committed scroll state.

methodgetRenderScrollState
getRenderScrollState(): ScrollManagerState

Returns the scroll state that render strategies should use for viewport copy planning.

deltaX and deltaY are computed from the last position marked as rendered to the current committed position. This keeps wheel scrolling and programmatic scrollTo() jumps on the same delta convention expected by RasterCopyPlan: previous minus current.

methodgetShape
getShape(): [number, number]

Returns the viewport dimensions as [width, height].

methodgetState
getState(): ScrollManagerState

Returns the current committed scroll state.

methodhasUnrenderedScroll
hasUnrenderedScroll(): boolean

Returns whether the current scroll position has not yet been rendered.

methodmarkScrollStateRendered
markScrollStateRendered(): void

Marks the current committed scroll position as consumed by a render frame.

methodrequestScrollTo
requestScrollTo(x: number, y: number): void

Requests an absolute scroll position through the owning editor.

x: number
y: number
methodresize
resize(width: number, height: number): void

Updates viewport dimensions and clamps the current position without emitting a scroll render.

width: number
height: number
methodscrollTo
scrollTo(x: number, y: number): void

Programmatically scroll to an absolute position, clamped to the content boundary, and notify all subscribers so the render pipeline re-draws.

x: number
y: number
methodsetContentBoundary
setContentBoundary(maxWidth: number, maxHeight: number): void

Set the content boundary for scroll clamping.

maxWidth: number

Maximum scrollable x position (contentWidth - viewportWidth)

maxHeight: number

Maximum scrollable y position (contentHeight - viewportHeight)

This should be called after initialization once the total sheet dimensions are known (e.g. by expandTreeBoundaryToSheetSize).

methodsetInputUpdateExecutor
setInputUpdateExecutor(executor: (state: ScrollManagerState): void): void

Routes platform-originated viewport input through the host's action boundary.

executor: (state: ScrollManagerState): void
methodsetPosition
setPosition(x: number, y: number): void

Directly set the scroll position (x, y) in the manager's state.

Useful for programmatic scroll jumps (e.g. "scroll to cell A1"). For normal scroll events, use addPublisher + update() instead, which clamps the position to the content boundary.

x: number
y: number
methodsetScrollToExecutor
setScrollToExecutor(executor: (x: number, y: number): void): void

Binds programmatic scroll requests to the owning editor's command bus.

executor: (x: number, y: number): void
methodsubscribeScroll
subscribeScroll(callback: ScrollSubscriber, prepend?: boolean): (): void

Subscribes to scroll-state changes and returns an idempotent disposer. prepend is reserved for updates that must run before render strategies.

callback: ScrollSubscriber
prepend: boolean
classWebScrollersource ↗
class WebScroller extends Scroller

Adapts a Web scroll surface to logical editor viewport coordinates.

constructorconstructor
WebScroller(target: unknown, platform: Platform): WebScroller

Creates a WebScroller instance.

target: unknown
platform: Platform
propertysymbolstatic
readonly symbol: symbol

DI token for resolving WebScroller.

memberroot
root: unknown
methodconfigureAxisLock
configureAxisLock(config: Partial<ScrollAxisLockConfig>): void

Enables or tunes Safari-style dominant-axis locking for wheel and touch gestures.

config: Partial<ScrollAxisLockConfig>
methodconfigureRubberBand
configureRubberBand(config: Partial<RubberBandConfig>): void

Enables or tunes the Safari-style overscroll effect. Logical editor coordinates remain clamped; only the visible surface moves.

config: Partial<RubberBandConfig>
methodgetPublisher
getPublisher(): (scrollStateInstance: ScrollManager, updateState: (newState: ScrollManagerState): void): (): void

Returns the publisher.

Inherited members 2

Inherited from Scroller.

interfaceRubberBandConfigsource ↗
interface RubberBandConfig

Host-tunable parameters for Safari-style boundary resistance and return motion.

propertyenabled
enabled: boolean
propertymaxOffset
maxOffset: number

Smooth asymptotic maximum visual displacement in viewport pixels.

propertyresistance
resistance: number

Initial slope of the rubber-band curve. Lower values reduce sensitivity.

propertyreturnDelay
returnDelay: number

Default delay used when release is called without an explicit delay.

propertyspringDamping
springDamping: number

Viscous damping used by the damped harmonic return motion.

propertyspringMass
springMass: number

Spring mass used by the damped harmonic return motion.

propertyspringStiffness
springStiffness: number

Spring stiffness used by the damped harmonic return motion.

interfaceRubberBandInputsource ↗
interface RubberBandInput

One logical input sample consumed by RubberBandController.

propertyboundary
readonly boundary: RubberBandOffset
propertycontinueReturnOnOutwardInput
readonly continueReturnOnOutwardInput?: boolean

Keeps an already scheduled return alive for same-direction wheel inertia.

propertydisplacement
readonly displacement: RubberBandOffset

Content displacement: positive values move the visible surface right/down.

propertyposition
readonly position: RubberBandOffset
propertyviewport
readonly viewport: RubberBandOffset
interfaceRubberBandOffsetsource ↗
interface RubberBandOffset

Transient visual displacement in viewport pixels.

propertyx
readonly x: number
propertyy
readonly y: number
interfaceScrollAxisLockConfigsource ↗
interface ScrollAxisLockConfig

Host-tunable direction-lock parameters for DOM scrolling gestures.

propertyactivationThreshold
activationThreshold: number

Accumulated pixels required before selecting the dominant axis.

propertyenabled
enabled: boolean
propertywheelEndDelay
wheelEndDelay: number

Wheel silence in milliseconds that separates two gestures.

interfaceScrollManagerStatesource ↗
interface ScrollManagerState

Scroll offset snapshot published to render and coordinate subscribers.

propertydeltaX
deltaX: number

Horizontal input delta that produced the update.

propertydeltaY
deltaY: number

Vertical input delta that produced the update.

propertyx
x: number

Current horizontal scroll offset in world coordinates.

propertyy
y: number

Current vertical scroll offset in world coordinates.

typeScrollAxissource ↗
type ScrollAxis = "x" | "y"

Axis selected for one continuous wheel or touch gesture.

typeScrollPublishersource ↗
type ScrollPublisher = (manager: ScrollManager, updateState: (newState: ScrollManagerState): void): (): void

Platform adapter that connects a scroll event source to ScrollManager.

functioncreateDefaultScrollManagerStatesource ↗
createDefaultScrollManagerState(): ScrollManagerState

Creates the default zero-offset scroll state.

functionrubberBandDistancesource ↗
rubberBandDistance(excess: number, viewport: number, resistance?: number, maxOffset?: number): number

Safari-like rubber-band mapping with a smooth maximum visual displacement.

excess: number
viewport: number
resistance: number
maxOffset: number