Seitu - Type-Safe Utilities
Web

Scroll State

createScrollState()

Creates a reactive handle that tracks scroll position of an element relative to each edge.

Examples

Vanilla

import {  } from 'seitu/web'

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

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

const  = .()
.()

React (with useRef)

page.tsx
'use client'

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

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

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

React (with useState)

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'}
    </>
  )
}

On this page