Interactions
In view
Play while the animation is on screen.
lottieInView() plays on entering the viewport and pauses on leaving:
import { Lottie, LottieInteractions, lottieInView } from "lottie-react";export function InView() { return ( <LottieInteractions interactions={[lottieInView()]}> <Lottie src="/anim.json" loop /> </LottieInteractions> );}Scroll it out of sight and back to watch both.
The options
once: trueplays on the first entry and then stops watching, so scrolling past again replays nothing.amountsays how much must be visible to count as entered,0to1. The default is0: a single visible pixel.margingrows or shrinks the viewport the entry is measured against, in the platform'srootMargingrammar: px or % only.
amount: 1 and tall animations
amount: 1 never fires for an animation taller than the viewport, because
such an element is never entirely visible. It warns in development.
A paused animation resumes on re-entry whether the pause was the behaviour's own or yours: the two are indistinguishable to it.