docs.rodeo

MDN Web Docs mirror

CSS scroll-driven animations

{{CSSRef}} 

The CSS scroll-driven animations module provides functionality that builds on top of the CSS animations module and Web Animations API. It allows you to animate property values based on a progression along a scroll-based timeline instead of the default time-based document timeline. This means that you can animate an element by scrolling a scrollable element, rather than just by the passing of time.

There are two types of scroll-based timelines:

When one of these two timelines is applied to an animated element, the animation progresses along that timeline instead of following the default time-based timeline.

It is possible to adjust the effective placement of the animation along the scroll progress and view progress timelines, i.e., you can define the position at which the animation starts and ends. This can be done in a couple of different ways:

Scroll-driven animations in action

You can find several tools and demos showing scroll-driven animations in action at Scroll-driven Animations tools and demos.

Reference

Properties

Set the timeline that will control the progress of an animation, and set its attachment range along that timeline:

Define named scroll progress timelines:

Define named view progress timelines:

Modify timeline scope:

At-rules

CSS scroll-driven animations adds the ability to include <timeline-range-name>s in {{cssxref("@keyframes")}}  blocks, to place keyframes at specific positions inside named timeline ranges.

Functions

Possible values of the {{cssxref("animation-timeline")}}  property for defining anonymous scroll progress timelines and anonymous view progress timelines (i.e. implicitly defined by the browser rather than being explicitly named and defined using the scroll-timeline-* and view-timeline-* properties):

Interfaces

Specifications

{{Specifications}} 

See also

In this article

View on MDN