Home
Docs
InfinityFX
©Copyright2016-2026 InfinityFX. All rights reserved.
InfinityFX®
Lively
v5.0.0
Getting started
Components
Animate
LayoutGroup
TextAnimation
ViewAnimation
Hooks
useAudio
useHover
useLink
useReducedMotion
useScroll
useSpring
useTap
useViewport
useVisible
Links
v4 docs
llms.txt

useViewport

Tracks an element's relative location inside the screen viewport and exposes a reactive AnimationLink containing normalized x and y coordinates from 0 to 1.

Importing

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

Usage

Target

Call signature

1
const [ref, link] = useViewport<T extends Element>(threshold?)

Parameters

threshold?:number = 0.5

The relative offset ratio inside the target element to measure.

Returns

ref:React.RefObject<T | null>

A React ref to attach to the target element.

link:AnimationLink<{ x: number, y: number }>

A reactive AnimationLink containing relative viewport position ratios from 0 to 1.