Seitu
Web

Scroll State

Tracks an element's scroll position relative to each edge.

createScrollState()

Notifies on scroll and ResizeObserver (not inner content growth — call '~'.notify() after that). The element getter is resolved on first subscribe; recreate the handle if the element identity changes (React: deps).

Vanilla

import {  } from 'seitu/web'

const  = ({
  : .('.container'),
  : 'vertical',
  : 10,
})

.( => {
  .(..)
  .(..)
  .(..)
  .(..)
})

const  = .()
.()

React (callback ref)

page.tsx
'use client'

import * as React from 'react'
import {  } from 'seitu/web'
import {  } from 'seitu/react'

function () {
  const [, ] = React.<HTMLDivElement | null>(null)
  const  = (() => ({
    : ,
    : 10,
  }), { : [] })

  return (
    < ={}>
      {.. ? 'at the top' : 'scrolled'}
    </>
  )
}
Edit on GitHub

Last updated on

On this page