Reveal animation options reference
All packages use the same options, with the same default values. In React, Vue and Astro, an option is a prop of Reveal and Cascade. Some options are not available in all APIs. See Where you can use each option. The React hooks, the Vue directives and the core functions take the options as an object.
Summary
Section titled “Summary”| Option | Type | Default |
|---|---|---|
from |
Side | StartState |
"bottom" |
keyframes |
Keyframe[] |
|
duration |
number |
600 |
delay |
number |
0 |
threshold |
number |
0 |
interval |
number |
80 |
when |
boolean | null |
|
onReveal |
(element: Element) => void |
|
as |
tag name | "div" |
Where you can use each option
Section titled “Where you can use each option”from,keyframes,duration,delayandthresholdwork with all APIs.intervalworks with the cascade APIs:- React:
CascadeanduseCascade. - Vue:
Cascadeandv-cascade. - Astro:
Cascade. - JavaScript:
cascade().
- React:
whenworks with all APIs of React, Vue and Astro. JavaScript does not have it.onRevealhas these limits:- React: all APIs.
- Vue:
v-revealandv-cascade. The components emit arevealevent. - Astro: not available. Listen to
revealevents. - JavaScript: not available.
asworks withRevealandCascadein React, Vue and Astro.
Entrance options
Section titled “Entrance options”Type: "top" | "right" | "bottom" | "left" | StartState. Default: "bottom".
Sets the start state of the entrance. A side gives a fade and a movement of 24 pixels from that side. A StartState object sets the complete start state, with the properties opacity, x, y, scale, rotate and blur. A number is in pixels for x, y and blur, and in degrees for rotate. A string contains a CSS value with its unit.
You cannot use from and keyframes together. See Choose the entrance.
keyframes
Section titled “keyframes”Type: Keyframe[]. No default.
Replaces the generated entrance with native Web Animations keyframes. Use it for a different easing or for properties that from does not animate.
- End the keyframes at the resting style of the element. The entrance does not keep its last keyframe.
- Give explicit values to the first keyframe.
- Set the easing in the keyframes. No option sets the easing.
duration
Section titled “duration”Type: number. Default: 600.
The duration of the entrance, in milliseconds.
Type: number. Default: 0.
The time between the reveal and the start of the entrance, in milliseconds. The element keeps its start state during the delay. Keep delay below about 300 milliseconds. A long delay makes content appear late when the user scrolls quickly.
Viewport options
Section titled “Viewport options”threshold
Section titled “threshold”Type: number, from 0 to 1. Default: 0.
The visible fraction of the element that reveals it. With 0, the element reveals when its first pixel enters the viewport. With 0.5, it reveals when half of it is visible.
If the viewport is too small to show this fraction of the element, the element reveals when it enters the viewport. Keep the default for tall elements and long cascades.
Cascade options
Section titled “Cascade options”interval
Section titled “interval”Type: number. Default: 80.
The time between the entrances of two direct element children, in milliseconds. The child at position index waits delay + index * interval. A negative value starts each later child further into its entrance.
Only Cascade, useCascade, v-cascade and cascade() accept interval.
Control options
Section titled “Control options”@awesome-reveal/core does not have these options. Astro does not have onReveal, and in Vue only the directives accept it.
Type: boolean | null. No default.
Controls the entrance manually. true reveals the element, and false resets the entrance, with no exit animation. With no value or null, the viewport controls the entrance. A change from true to null keeps the element revealed. To play the entrance again, set when to false, then to true.
when does not show or hide content. With false, the element is transparent, but screen readers read it and the keyboard can focus its controls. To hide content, also set hidden, or do not render it. If the user asks for reduced motion, the element reveals also when when is false.
In Astro, to change when in a client script, use getReveal.
onReveal
Section titled “onReveal”Type: (element: Element) => void. No default.
Runs one time for each reveal, when the reveal starts. It also runs when no entrance plays, for example with reduced motion. It gets the revealed element.
- In Vue, the
RevealandCascadecomponents emit arevealevent. Thev-revealandv-cascadedirectives acceptonReveal. - In Astro, the rendered tag dispatches a
revealevent that bubbles.
Component props
Section titled “Component props”Type: a tag name. Default: "div".
Sets the tag that Reveal and Cascade render, for example "section" or "ul". The other attributes of the component go to this tag.
In Astro, as cannot be a document tag (html, head or body), a table part (such as tr or td) or a tag that exists only in SVG. The HTML parser moves these tags out of the custom element.