Skip to content

JavaScript scroll reveal API

@awesome-reveal/core exports two functions. They work with no framework, and they need no stylesheet.

import { cascade, reveal } from "@awesome-reveal/core";

For server rendering, see The JavaScript API.

reveal(target: RevealTarget, options?: RevealOptions): RevealHandle

Reveals each target when it enters the viewport.

  • options: from, keyframes, duration, delay and threshold. See Options.
  • Return value: a RevealHandle.
cascade(target: RevealTarget, options?: CascadeOptions): RevealHandle

Reveals the direct element children of each target, one after the other, when the target enters the viewport. See Animate a list.

target is one of these values:

  • an element
  • a CSS selector, such as ".card"
  • an iterable of elements, such as an array or a NodeList
  • an array-like collection, such as element.children

The function finds the targets, and the children of a cascade, one time, when you call it. It does not see elements that you add later. Call it again for new elements.

For a selector that is not valid, see Errors.

The return value of reveal() and cascade(). It has one method.

Stops the observation and the animations of the call. Each element returns to its resting style. Call it when you remove the elements, for example when your component unmounts.

A finished entrance needs no dispose(). See One entrance for each element.

Type Description
RevealOptions The options of reveal().
CascadeOptions The options of cascade().
RevealTarget The targets that the functions accept.
RevealHandle The return value of the functions.
Side The sides of from.
StartState The start state object of from.