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 */
timeline-trigger-activation-range-end: normal;

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

/* Named timeline range */
timeline-trigger-activation-range-end: contain;
timeline-trigger-activation-range-end: exit;

/* Named timeline range plus offset */
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;

Values

Specified as one or more values, separated by commas. Possible values are:

normal

The default value. Equivalent to cover 100% for a view progress timeline timeline-trigger-source, and scroll 100% for a scroll progress timeline timeline-trigger-source.

<length-percentage>

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

<timeline-range-name>

Specifies the end (100%) of the named timeline range.

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

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

Percentages are relative to the length of the named timeline range if one is specified, or the timeline represented by normal if not.

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.

The default value, normal, is equivalent to cover 100% for a view progress timeline timeline-trigger-source, and scroll 100% for a scroll progress timeline timeline-trigger-source.

If the <timeline-range-name> value does not include a <length-percentage>, it defaults to 100% of the named timeline range. If a <timeline-range-name> is not included, the timeline range defaults to cover for a view progress timeline source, and scroll for a scroll progress timeline source.

The timeline-trigger-activation-range-end property, along with the timeline-trigger-activation-range-start property, can also be set using the timeline-trigger-activation-range shorthand.

Specifying multiple range end values

When you specify multiple comma-separated values on a single timeline-trigger-activation-range-end property, they are applied to the timeline triggers in the order in which the timeline-trigger-names appear. When the number of triggers and timeline-trigger-activation-range-end property values do not match, they are applied in the same way as multiple animation property values.

For example, 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.

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, --my-trigger will use the cover range end and --my-other-trigger will use the entry 100% range end. As there are three names but only two range ends, the range ends are cycled, so the third trigger name, --another-trigger, will use the cover range end.

Formal definition

Initial valuenormal
Applies toall elements
Inheritedno
PercentagesRelative to the specified named timeline range if specified, otherwise relative to the entire timeline
Computed valueA list where each item may be 'normal', a length percentage, or a timeline range name and a length percentage
Animation typeNot animatable

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 inset the end of a scroll-triggered animation trigger's activation range by setting a custom timeline-trigger-activation-range-end value.

HTML

Our markup contains two <div> elements, one to animate and one on which to create a trigger, 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's position is set to fixed, positioning it near the top-left of the scrollport to enable us to see when its animation starts and stops.

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

Next, we define the @keyframes for the rotate animation we will use later:

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

  to {
    rotate: 360deg;
  }
}

Using the animation shorthand, the .animated element has the rotate animation applied. Without an associated trigger, the element would start animating when the page loads. The animation-trigger property makes it a triggered animation. The value references a timeline-trigger-name of --t and specifies two <animation-action> values — play and pause — which specify that the animation will play on activation, and pause on deactivation.

css
.animated {
  animation: rotate 3s infinite linear;
  animation-trigger: --t play pause;
}

The .trigger <div> element creates the animated <div>'s trigger via the following properties:

  • A timeline-trigger-name with value --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 with value 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 scrollport in either direction). When not explicitly set, the timeline-trigger-activation-range-start value defaults to normal, which in this case is 0% of the way through the cover range, meaning that on activation, the animation will start when the tracked element enters the scrollport's end edge.
css
.trigger {
  timeline-trigger-name: --t;
  timeline-trigger-source: view();
  timeline-trigger-activation-range-end: contain 60%;
}

Result

Try scrolling the content up. The animation plays when the tracked <div> first becomes visible at the scrollport end edge and pauses when it has scrolled 60% of the way up the timeline range. When you scroll down, the effect happens in reverse — the animation plays when it gets to 60% of the way up, and pauses when it reaches the end edge.

Specifications

Specification
Animation Triggers
# propdef-timeline-trigger-activation-range-end

Browser compatibility

See also