Interface: ViewportEngine
@roomful/core / ViewportEngine
Interface: ViewportEngine
Section titled “Interface: 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.
Methods
Section titled “Methods”broadcast()
Section titled “broadcast()”broadcast():
void
Defined in: packages/core/src/types.ts:1551
Starts streaming the local viewport to all peers.
Returns
Section titled “Returns”void
Nothing.
follow()
Section titled “follow()”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.
Parameters
Section titled “Parameters”peerId
Section titled “peerId”string
The peer whose viewport to follow.
Returns
Section titled “Returns”void
Nothing.
get(
peerId):ViewportState|undefined
Defined in: packages/core/src/types.ts:1613
Looks up a single peer’s viewport state.
Parameters
Section titled “Parameters”peerId
Section titled “peerId”string
The peer identifier to resolve.
Returns
Section titled “Returns”ViewportState | undefined
The matching viewport state, or undefined when none is known.
getAll()
Section titled “getAll()”getAll():
ViewportState[]
Defined in: packages/core/src/types.ts:1605
Returns all remote viewport states.
Returns
Section titled “Returns”The current remote viewport states.
mount()
Section titled “mount()”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).
Parameters
Section titled “Parameters”element
Section titled “element”HTMLElement
The container element to observe.
Returns
Section titled “Returns”void
Nothing.
present()
Section titled “present()”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.
Returns
Section titled “Returns”void
Nothing.
stopBroadcast()
Section titled “stopBroadcast()”stopBroadcast():
void
Defined in: packages/core/src/types.ts:1558
Stops streaming the local viewport.
Returns
Section titled “Returns”void
Nothing.
stopPresenting()
Section titled “stopPresenting()”stopPresenting():
void
Defined in: packages/core/src/types.ts:1573
Leaves present mode and releases peers that were following.
Returns
Section titled “Returns”void
Nothing.
subscribe()
Section titled “subscribe()”subscribe(
cb):Unsubscribe
Defined in: packages/core/src/types.ts:1598
Subscribes to remote viewport updates.
Parameters
Section titled “Parameters”(states) => void
The callback invoked with the current remote viewport states.
Returns
Section titled “Returns”A function that removes the listener.
unfollow()
Section titled “unfollow()”unfollow():
void
Defined in: packages/core/src/types.ts:1590
Stops following any peer and resumes independent scrolling.
Returns
Section titled “Returns”void
Nothing.
unmount()
Section titled “unmount()”unmount():
void
Defined in: packages/core/src/types.ts:1544
Stops observing the element and applies pending teardown.
Returns
Section titled “Returns”void
Nothing.