vael-ui v0.5.7

Motion

useScrollLength

How far the page or a container can scroll, in px, as a ref. It follows the content growing or shrinking.

How far the page, or a scrolling container, can scroll, in px, as a ref. It follows the content growing or shrinking, as rows loading in, and the window resizing. Pair it with useScrollProgress to turn progress into a distance: progress.value * length.value.

Install

import { useScrollLength } from 'vael-ui/motion'

Examples

Parameters

NameTypeDescription
containerMaybeRefOrGetter<Element | null | undefined>A scrolling element. Leave it out for the page.
options.axis'x' | 'y'Which way it scrolls. Default 'y'.

Returns

NameTypeDescription
lengthReadonly<Ref<number>>The scrollable distance in px: the content past what shows. 0 on the server.