timeline-trigger-activation-range-end CSS property

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The timeline-trigger-activation-range-end CSS property specifies the end point of a scroll-triggered animation trigger's activation range.

Syntax

css
/* Keyword or <length-percentage> */
timeline-trigger-activation-range-end: normal;
timeline-trigger-activation-range-end: 80%;
timeline-trigger-activation-range-end: 400px;

/* Named timeline range value */
timeline-trigger-activation-range-end: contain;
timeline-trigger-activation-range-end: exit;
timeline-trigger-activation-range-end: entry 100%;
timeline-trigger-activation-range-end: contain 600px;

/* Multiple range end values */
timeline-trigger-activation-range-end:
  contain,
  entry 100%;

/* Global values */
timeline-trigger-activation-range-end: inherit;
timeline-trigger-activation-range-end: initial;
timeline-trigger-activation-range-end: revert;
timeline-trigger-activation-range-end: revert-layer;
timeline-trigger-activation-range-end: unset;

The timeline-trigger-activation-range-end property is specified as one or more values, separated by commas.

Values

normal

Represents the end of the timeline. This is the default value.

<length-percentage>

Specifies a length or percentage value measured from the beginning of the timeline.

<timeline-range-name>

Specifies a named timeline range within the overall timeline. The range starts at 0%.

<timeline-range-name> <length-percentage>

Specifies a length or percentage value measured from the beginning of the specified named timeline range.

Description

When creating CSS scroll-triggered animations, the timeline-trigger-activation-range-end property can be used to explicitly define the end of the trigger's activation range. Read the linked guide and the timeline-trigger-activation-range description for more information.

Allowed values for the timeline-trigger-activation-range-end property are:

  • normal
  • A <length-percentage>
  • A <timeline-range-name>
  • A <timeline-range-name> and a <length-percentage> separated by a space.

If the <timeline-range-name> value does not include a <length-percentage>, the percentage defaults to 100%.

The timeline-trigger-activation-range-end, along with the timeline-trigger-activation-range-start property, can both be set in a single declaration using the timeline-trigger-activation-range shorthand.

Specifying multiple range end values

When multiple values are specified in a single timeline-trigger-activation-range-end property, they are distributed between the specified timeline-trigger-name values in the same fashion as multiple animation values are distributed (see Setting multiple animation property values).

If multiple timeline-trigger-name values are set, but only a single timeline-trigger-activation-range-end value is set, the timeline-trigger-activation-range-end will apply to all the timeline-trigger-names. If two timeline-trigger-activation-range-end values are set, they will cycle between the timeline-trigger-names until all of them have a timeline-trigger-activation-range-end value set. And so on.

For example, consider these declarations:

css
timeline-trigger-name: --my-trigger, --my-other-trigger, --another-trigger;
timeline-trigger-activation-range-end:
  cover,
  entry 100%;

In this case, the first name will use the cover range end, and the second name will use the entry 100% range end. The third name will cycle back to using the cover range end again.

Formal definition

Value not found in DB!

Formal syntax

timeline-trigger-activation-range-end = 
[ normal | <length-percentage> | <timeline-range-name> <length-percentage>? ]#

<length-percentage> =
<length> |
<percentage>

Examples

Basic usage

In this example, we show how to create a basic scroll-triggered animation with a custom activation range end value.

HTML

Our markup contains two <div> elements, plus some basic text content to cause the page to scroll. We have hidden the text content for brevity.

html
<div class="animated">I am animated</div>

...

<div class="trigger">I create the trigger</div>

...

CSS

The .animated <div> element has an animation applied that rotates it. We set an animation-trigger value on it that references a trigger name of --t; we also specify two <animation-action> values — play and pause — which specify that the animation will play on activation, and pause on deactivation.

The .trigger <div> element creates the animated <div>'s trigger using:

  • A timeline-trigger-name value of --t, which is equal to the identifier referenced in the animated <div>'s animation-trigger property value, associating the two together.
  • A timeline-trigger-source value of view(), which sets the timeline trigger as a view progress timeline, and the element providing the timeline trigger as the nearest scrolling ancestor element.
  • A timeline-trigger-activation-range-end of contain 60%, which sets the trigger's activation range end point to 60% of the way through the contain range (when the tracked element has scrolled a little over half way through the viewport in either direction). The timeline-trigger-activation-range-start value defaults to 0% of the way through the cover range, meaning that the animation will start when the tracked element has started to enter the viewport.
css
div.animated {
  animation: rotate 3s infinite linear both;
  animation-trigger: --t play pause;
}

div.trigger {
  timeline-trigger-name: --t;
  timeline-trigger-source: view();
  timeline-trigger-activation-range-end: contain 60%;
}

Next, we give the animated <div> a position of fixed, positioning it near the top-left of the viewport so that we can easily see when its animation starts and stops.

css
div.animated {
  position: fixed;
  top: 25px;
  left: 25px;
}

Finally, we define the @keyframes for the rotate animation:

css
@keyframes rotate {
  from {
    rotate: 0deg;
  }

  to {
    rotate: 360deg;
  }
}

Result

The rendered result looks like this:

Try scrolling the content up. When the tracked <div> starts to enter the viewport, the animation will play; when the tracked <div> has scrolled a little over half-way up the viewport, the animation will pause.

Specifications

This feature does not appear to be defined in any specification.

Browser compatibility

See also