Skip to content

Interface: ViewportEngine

@roomful/core


@roomful/core / ViewportEngine

Defined in: packages/core/src/types.ts:1528

Exposes viewport synchronization for a room. A viewport engine streams this peer’s scroll/zoom/dimensions and applies a followed peer’s viewport to the mounted container.

broadcast(): void

Defined in: packages/core/src/types.ts:1551

Starts streaming the local viewport to all peers.

void

Nothing.


follow(peerId): void

Defined in: packages/core/src/types.ts:1583

Follows a specific peer’s viewport, applying their scroll position to the mounted element as their viewport changes. Zoom is exposed in state for the app to apply.

string

The peer whose viewport to follow.

void

Nothing.


get(peerId): ViewportState | undefined

Defined in: packages/core/src/types.ts:1613

Looks up a single peer’s viewport state.

string

The peer identifier to resolve.

ViewportState | undefined

The matching viewport state, or undefined when none is known.


getAll(): ViewportState[]

Defined in: packages/core/src/types.ts:1605

Returns all remote viewport states.

ViewportState[]

The current remote viewport states.


mount(element): void

Defined in: packages/core/src/types.ts:1537

Observes the element’s scroll, zoom, and dimensions, and broadcasts them as the local viewport while broadcasting is active. The engine mounts on a scrollable container element (not window).

HTMLElement

The container element to observe.

void

Nothing.


present(): void

Defined in: packages/core/src/types.ts:1566

Enters present mode: broadcasts the local viewport and signals peers to follow it until ViewportEngine.stopPresenting is called.

void

Nothing.


stopBroadcast(): void

Defined in: packages/core/src/types.ts:1558

Stops streaming the local viewport.

void

Nothing.


stopPresenting(): void

Defined in: packages/core/src/types.ts:1573

Leaves present mode and releases peers that were following.

void

Nothing.


subscribe(cb): Unsubscribe

Defined in: packages/core/src/types.ts:1598

Subscribes to remote viewport updates.

(states) => void

The callback invoked with the current remote viewport states.

Unsubscribe

A function that removes the listener.


unfollow(): void

Defined in: packages/core/src/types.ts:1590

Stops following any peer and resumes independent scrolling.

void

Nothing.


unmount(): void

Defined in: packages/core/src/types.ts:1544

Stops observing the element and applies pending teardown.

void

Nothing.