Primitives / foldkit-primitives/state

WindowViewport

const · packages/primitives/src/state/virtual.ts:392

const WindowViewport: Mount.MountDefinitionNoArgs<
  'WindowViewport',
  {
    readonly _tag: 'ViewportPlaced'
    readonly top: number
    readonly height: number
  }
>

Where the window's viewport lies over a list that scrolls with the document: top is how far the viewport's top edge is past the element's (negative while the element is still below it), height the viewport's. Attach to the list's own box. It reports as it mounts, on the window's scroll and resize, and when the box or the document's root element changes size, which is how content above the list growing shows: the offset moves with no scroll. An unchanged reading is sent once.

In the guides