Skip to content

Animation duration, delay and threshold

Three options set when the entrance plays and how long it takes: duration, delay and threshold.

duration sets the duration of the entrance, in milliseconds. The default is 600. Select a duration to see the effect:

duration

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>
);
}

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.

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>
</>
);
}

Keep delay below about 300 milliseconds. A long delay makes content appear late when the user scrolls quickly.

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>
);
}

A change to threshold applies immediately in React, Vue and Astro. A change to duration or delay applies at the next reveal.

  • 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.

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.