useScroll

Creates a reactive Link whose value is the current scroll position of a target element.

Importing

1
import { useScroll } from '@infinityfx/lively/hooks';

Usage

Call signature

1
const link = useScroll({ restore, target })

Parameters

restore?:number = 0

Duration in seconds to animate the initial scroll position over on page load.

target?:React.RefObject<T extends HTMLElement>

A React ref pointing to an HTMLElement for use as the scroll container. If no target is passed the window object will be used as the scroll container.

Returns

link:Link<{ x: number; y: number; left: number; top: number; }>

A link which can be used inside the animate property to create an animation.