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()
Section titled “reveal()”reveal(target: RevealTarget, options?: RevealOptions): RevealHandleReveals each target when it enters the viewport.
options:from,keyframes,duration,delayandthreshold. See Options.- Return value: a
RevealHandle.
cascade()
Section titled “cascade()”cascade(target: RevealTarget, options?: CascadeOptions): RevealHandleReveals the direct element children of each target, one after the other, when the target enters the viewport. See Animate a list.
options: the options ofreveal(), andinterval.- Return value: a
RevealHandle.
Targets
Section titled “Targets”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.
RevealHandle
Section titled “RevealHandle”The return value of reveal() and cascade(). It has one method.
dispose()
Section titled “dispose()”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. |