Documentation

The plugin provides utilities for a subset of CSS scroll-driven animation properties:

  • animation-timeline
  • scroll-timeline, view-timeline
  • animation-range
  • timeline-scope

Animation Timeline

The single most impressive feature of scroll-driven animations is an anonymous animation timeline. It allows to easily trigger anything just by scrolling the page. Use the timeline utility which defaults to animation-timeline: scroll(y) and also provides an option to set custom timeline name with a modifier.

Class
/
Code
timeline
animation-timeline: scroll(y);
timeline-scroll-x
animation-timeline: scroll(x);
timeline-view
animation-timeline: view();
timeline-auto
animation-timeline: auto;
timeline-none
animation-timeline: none;
timeline/{name}
animation-timeline: --{name};

Anonymous Scroll Timeline Demo

This demo showcases how to create a simple progress bar just by adding one utility class to the element. We define the anonymous scroll timeline by adding timeline to the progress bar.

animate-scale-to-right timeline
0%scroll(y)
100%scroll(y)
<div> <div class="animate-scale-to-right timeline"> <!-- The progress bar is controlled by the anonymous scroll(y) timeline. --> </div> <div> ... </div> </div>
@keyframes scale-to-right { to { width: 100%; } }

Anonymous View Timeline Demo

This demo showcases how to make the element appear after entering the view frame. We define the anonymous view timeline by adding timeline-view to this element.

0%The element enters the frame
animate-appear timeline-view
100%The element leaves the frame
<div> ... <div class="animate-appear timeline-view"> <!-- This element is controlled by its own anonymous view() timeline. --> </div> ... </div>
@keyframes appear { 0% { opacity: 0; transform: scale(0.5); } 40% { opacity: 1; transform: scale(1.1); } 60%, 100% { opacity: 1; transform: scale(1); } }

Named Timelines

Scroll Timeline

Utility class setting the named scroll progress timeline, which is set on a scrollable element.

Class
/
Code
scroll-timeline/{name}
scroll-timeline: --{name} y;
scroll-timeline-x/{name}
scroll-timeline: --{name} x;
scroll-timeline-block/{name}
scroll-timeline: --{name} block;

View Timeline

Utility class setting the named view progress timeline, which is set on a subject inside another scrollable element.

Class
/
Code
view-timeline/{name}
view-timeline: --{name} y;
view-timeline-x/{name}
view-timeline: --{name} x;
view-timeline-block/{name}
view-timeline: --{name} block;

Animation Range

Animation range start controls where along the timeline an animation will start. It is set on the animated element.

Class
/
Code
range
animation-range: cover 0% cover 100%;
range-contain
animation-range: contain 0% contain 100%;
range-on-entry
animation-range: entry 0% entry 100%;
range-on-exit
animation-range: exit 0% exit 100%;
range/{startValue}_{endValue}
animation-range: cover {value} cover {endValue};

Animation Range Demo

Scroll the container to see each how range utility class affects the animation.

range-on-entry
0%100%
range
0%100%
range-contain
0%100%
range-on-exit
0%100%
view-timeline/demo
<div class="scope/demo"> <!-- The --demo timeline has scope outside its defining element --> <div class="animate-scale-to-right range-on-entry timeline/demo"> <!-- This element is controlled by the --demo timeline --> </div> ... <div className="view-timeline/demo"> <!-- Controlling element --> </div> </div>
@keyframes scale-to-right { to { width: 100%; } }

Timeline Scope

Timeline scope allows to control animations outside the element which defines the timeline.

Class
/
Code
scope/{name}
timeline-scope: --{name};

Range, Scope and Animation Timeline Name Demo

This demo showcases the usage of the plugin to reveal the navigation bar. The view-timeline/navbar utility sets up the animation timeline, which is then scoped out of the defining element by scope/navbar. The navigation bar is controlled by this timeline with the timeline/navbar utility. Utility class range-on-exit is set to limit the timeline duration.

animate...timeline/navbarrange-on-exit
scope/navbar
0%The element starts leaving the frame
view-timeline/navbar
100%The element leaves the frame
<div class="scope/navbar"> <!-- The --navbar timeline has scope outside its defining element --> <div class="animate-translate-down timeline/navbar range-on-exit"> <!-- Navbar is shown when the controlling element leaves the frame --> </div> <div> ... <div className="view-timeline/navbar"> <!-- Controlling element --> </div> ... </div> </div>
@keyframes translate-down { to { translate: 0; } }

Fallback Styling

Use the no-animations modifier to apply fallback styling in browsers which do not support scroll-driven animations yet.

Class
/
Code
no-animations:...
@supports not (animation-range: cover) { ... };

Fallback Demo

animate...timeline-translate-y-20no-animations:translate-y-0
<div> <div class="animate-translate-down timeline -translate-y-20 no-animations:translate-y-0"> <!-- This element falls back to translate-y-0 --> </div> ... </div>
Created by Adam Plesník, Bratislava, Slovakia