JavaScript scroll animations
Use @awesome-reveal/core to add scroll animations to a page with no framework. An element fades and slides in when it scrolls into view. The package does not link an animation to the scroll position, as a parallax effect or a scroll progress bar does.
Install the package
Section titled “Install the package”pnpm add @awesome-reveal/coreFor the supported browsers, see Browser support.
Reveal elements on scroll
Section titled “Reveal elements on scroll”Call reveal() with a CSS selector, an element or a list of elements:
import { reveal } from "@awesome-reveal/core";
reveal(".card");reveal(".hero", { from: "left" });reveal(".logo", { from: { opacity: 0, scale: 0.9 } });from sets the entrance. To fade, zoom, rotate or blur the element in, set a start state.
For elements that you add later, see Targets.
Stagger a list
Section titled “Stagger a list”cascade() reveals the direct children of each container one after the other:
import { cascade } from "@awesome-reveal/core";
cascade(".features", { from: { opacity: 0, y: 16 }, interval: 120 });For a long list or a tall grid, see Animate a list.
Stop the reveals
Section titled “Stop the reveals”reveal() and cascade() return a handle. When you remove the elements before they reveal, call dispose():
import { reveal } from "@awesome-reveal/core";
const handle = reveal(".card");
// When a single-page app leaves the route:handle.dispose();Server-rendered pages
Section titled “Server-rendered pages”@awesome-reveal/core does not hide content before your script runs. See The JavaScript API. For server-rendered pages, use React, Vue or Astro.
Next steps
Section titled “Next steps”- Use your own keyframes: give native Web Animations keyframes.
- Change the timing: set the duration, the delay and the threshold.
- JavaScript API: the functions, the targets and the types.