SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

messageFollow

Bridges a message scroller's viewport to ScrollFollowModel, reporting live scroll position, viewport size.

tsx
import { messageFollow } from "@sdxc/ui/chat";

Usage

Adds live-scroll coordination to a message scroller's viewport: reports scroll position, size, and turn visibility into model, mirrors its pinned and reachable-edge state back onto the viewport, and fulfills its scroll requests.

Signature

typescript
messageFollow(model: ScrollFollowModel): MixinDescriptor<HTMLElement>

Parameters

ParameterTypeDefaultRequiredDescription
modelScrollFollowModel—YesScroll-follow state shared with the rest of the widget.

Examples

tsx
let model = new ScrollFollowModel();
<div class="viewport" mix={messageFollow(model)}>
  <div class="content">
    {turns.map((turn) => (
      <div key={turn.id} data-scroll-anchor={turn.id}>{turn.body}</div>
    ))}
  </div>
  <button data-scroll-jump aria-label={jumpToLatestLabel}>↓</button>
</div>

The events, constants and types its module publishes, each imported from @sdxc/ui/chat too.

Constant

MESSAGE_SCROLLER_ANCHOR_ATTRIBUTE

Attribute every conversational turn exposes itself on, its value the turn's stable id; messageFollow() reads it to find the anchor turn and to drive its lazily attached IntersectionObserver's visibility tracking.

typescript
const MESSAGE_SCROLLER_ANCHOR_ATTRIBUTE = "data-scroll-anchor"
Constant

MESSAGE_SCROLLER_JUMP_ATTRIBUTE

Attribute the viewport's jump-to-latest control carries. messageFollow() finds it beneath the viewport to wire its click and to mirror ScrollFollowModel.pinned onto its visibility and tab-order reachability.

typescript
const MESSAGE_SCROLLER_JUMP_ATTRIBUTE = "data-scroll-jump"
Constant

MESSAGE_SCROLLER_AUTOSCROLLING_ATTRIBUTE

Attribute messageFollow() mirrors onto the viewport whenever ScrollFollowModel.pinned is true — present while auto-follow is engaged, absent once the reader has scrolled away from the live edge.

typescript
const MESSAGE_SCROLLER_AUTOSCROLLING_ATTRIBUTE = "data-autoscrolling"
Constant

MESSAGE_SCROLLER_SCROLLABLE_ATTRIBUTE

Attribute messageFollow() mirrors onto the viewport: a space-separated token list of edges still reachable ("start", "end", or "start end"), readable via [data-scrollable~="end"]; removed once neither edge is reachable.

typescript
const MESSAGE_SCROLLER_SCROLLABLE_ATTRIBUTE = "data-scrollable"
@sdxc/ui

Can’t find it? Contact us