Animation duration, delay and threshold
Three options set when the entrance plays and how long it takes: duration, delay and threshold.
Change the duration
Section titled “Change the duration”duration sets the duration of the entrance, in milliseconds. The default is 600. Select a duration to see the effect:
Your device asks for reduced motion, so the content shows with no animation.
import { Reveal } from "@awesome-reveal/react";
export function FeatureCard() { return ( <Reveal className="card" duration={300}> A card </Reveal> );}import { Reveal } from "@awesome-reveal/react";
export function FeatureCard() { return ( <Reveal className="card" duration={600}> A card </Reveal> );}import { Reveal } from "@awesome-reveal/react";
export function FeatureCard() { return ( <Reveal className="card" duration={1000}> A card </Reveal> );}import { Reveal } from "@awesome-reveal/react";
export function FeatureCard() { return ( <Reveal className="card" duration={2000}> A card </Reveal> );}<script setup>import { Reveal } from "@awesome-reveal/vue";</script>
<template> <Reveal class="card" :duration="300">A card</Reveal></template><script setup>import { Reveal } from "@awesome-reveal/vue";</script>
<template> <Reveal class="card" :duration="600">A card</Reveal></template><script setup>import { Reveal } from "@awesome-reveal/vue";</script>
<template> <Reveal class="card" :duration="1000">A card</Reveal></template><script setup>import { Reveal } from "@awesome-reveal/vue";</script>
<template> <Reveal class="card" :duration="2000">A card</Reveal></template>---import { Reveal } from "@awesome-reveal/astro";---
<Reveal class="card" duration={300}> A card</Reveal>---import { Reveal } from "@awesome-reveal/astro";---
<Reveal class="card" duration={600}> A card</Reveal>---import { Reveal } from "@awesome-reveal/astro";---
<Reveal class="card" duration={1000}> A card</Reveal>---import { Reveal } from "@awesome-reveal/astro";---
<Reveal class="card" duration={2000}> A card</Reveal>import { reveal } from "@awesome-reveal/core";
reveal(".card", { duration: 300 });import { reveal } from "@awesome-reveal/core";
reveal(".card", { duration: 600 });import { reveal } from "@awesome-reveal/core";
reveal(".card", { duration: 1000 });import { reveal } from "@awesome-reveal/core";
reveal(".card", { duration: 2000 });Delay the entrance
Section titled “Delay the entrance”delay sets the time between the reveal and the start of the entrance, in milliseconds. The default is 0. The element keeps its start state during the delay.
In this example, the title takes 800 milliseconds. The text starts 200 milliseconds after its reveal, so it starts while the title still moves:
Welcome
The text starts after the delay.
Welcome
The text starts after the delay.
Welcome
The text starts after the delay.
Your device asks for reduced motion, so the content shows with no animation.
import { Reveal } from "@awesome-reveal/react";
export function PageIntro() { return ( <> <Reveal as="h2" from="left" duration={800}> Welcome </Reveal> <Reveal as="p" from={{ opacity: 0 }} delay={0}> The text starts after the delay. </Reveal> </> );}import { Reveal } from "@awesome-reveal/react";
export function PageIntro() { return ( <> <Reveal as="h2" from="left" duration={800}> Welcome </Reveal> <Reveal as="p" from={{ opacity: 0 }} delay={200}> The text starts after the delay. </Reveal> </> );}import { Reveal } from "@awesome-reveal/react";
export function PageIntro() { return ( <> <Reveal as="h2" from="left" duration={800}> Welcome </Reveal> <Reveal as="p" from={{ opacity: 0 }} delay={600}> The text starts after the delay. </Reveal> </> );}<script setup>import { Reveal } from "@awesome-reveal/vue";</script>
<template> <Reveal as="h2" from="left" :duration="800">Welcome</Reveal> <Reveal as="p" :from="{ opacity: 0 }" :delay="0"> The text starts after the delay. </Reveal></template><script setup>import { Reveal } from "@awesome-reveal/vue";</script>
<template> <Reveal as="h2" from="left" :duration="800">Welcome</Reveal> <Reveal as="p" :from="{ opacity: 0 }" :delay="200"> The text starts after the delay. </Reveal></template><script setup>import { Reveal } from "@awesome-reveal/vue";</script>
<template> <Reveal as="h2" from="left" :duration="800">Welcome</Reveal> <Reveal as="p" :from="{ opacity: 0 }" :delay="600"> The text starts after the delay. </Reveal></template>---import { Reveal } from "@awesome-reveal/astro";---
<Reveal as="h2" from="left" duration={800}> Welcome</Reveal><Reveal as="p" from={{ opacity: 0 }} delay={0}> The text starts after the delay.</Reveal>---import { Reveal } from "@awesome-reveal/astro";---
<Reveal as="h2" from="left" duration={800}> Welcome</Reveal><Reveal as="p" from={{ opacity: 0 }} delay={200}> The text starts after the delay.</Reveal>---import { Reveal } from "@awesome-reveal/astro";---
<Reveal as="h2" from="left" duration={800}> Welcome</Reveal><Reveal as="p" from={{ opacity: 0 }} delay={600}> The text starts after the delay.</Reveal>import { reveal } from "@awesome-reveal/core";
reveal(".intro h2", { from: "left", duration: 800 });reveal(".intro p", { from: { opacity: 0 }, delay: 0 });import { reveal } from "@awesome-reveal/core";
reveal(".intro h2", { from: "left", duration: 800 });reveal(".intro p", { from: { opacity: 0 }, delay: 200 });import { reveal } from "@awesome-reveal/core";
reveal(".intro h2", { from: "left", duration: 800 });reveal(".intro p", { from: { opacity: 0 }, delay: 600 });Keep delay below about 300 milliseconds. A long delay makes content appear late when the user scrolls quickly.
Reveal later with a threshold
Section titled “Reveal later with a threshold”threshold sets the visible fraction of the element that reveals it, from 0 to 1. The default is 0, so the element reveals when its first pixel enters the viewport. With 0.5, the element reveals when half of it is visible:
import { Reveal } from "@awesome-reveal/react";
export function DownloadsChart() { return ( <Reveal threshold={0.5}> <img src="/chart.svg" alt="Downloads for each month" /> </Reveal> );}<script setup>import { Reveal } from "@awesome-reveal/vue";</script>
<template> <Reveal :threshold="0.5"> <img src="/chart.svg" alt="Downloads for each month" /> </Reveal></template>---import { Reveal } from "@awesome-reveal/astro";---
<Reveal threshold={0.5}> <img src="/chart.svg" alt="Downloads for each month" /></Reveal>import { reveal } from "@awesome-reveal/core";
reveal(".chart", { threshold: 0.5 });A change to threshold applies immediately in React, Vue and Astro. A change to duration or delay applies at the next reveal.
Tall elements and small scroll containers
Section titled “Tall elements and small scroll containers”- If the viewport is too small to show the threshold fraction of the element, the element reveals when it enters the viewport.
- In a scroll container that is too small, the element reveals when it leaves the visible area of the container.
Keep the default threshold for tall elements and for long cascades.
The start state moves the box of reveal()
Section titled “The start state moves the box of reveal()”React, Vue and Astro hide a waiting element with CSS at its resting position. They create the entrance at the reveal, so the start state does not change the box that the viewport check uses.
reveal() of the JavaScript API holds a waiting element at the first keyframe of a paused entrance. A start state with opacity: 0, such as each side, waits at the resting position of the element. Other start states and your own keyframes wait at their first keyframe. Their offset, scale and rotation change the box that the viewport check uses. For example, with the start state { y: 80 }, the element waits 80 pixels lower, so it reveals later.
cascade() holds each child at its first keyframe, but the viewport check uses the box of the container. So the start state of the children does not change when the cascade reveals.