timeline-trigger-activation-range-start CSS property

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

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

Syntax

css
/* Keyword or <length-percentage> */
timeline-trigger-activation-range-start: normal;
timeline-trigger-activation-range-start: 20%;
timeline-trigger-activation-range-start: 350px;

/* Named timeline range value */
timeline-trigger-activation-range-start: cover;
timeline-trigger-activation-range-start: exit;
timeline-trigger-activation-range-start: entry 40%;
timeline-trigger-activation-range-start: contain 200px;

/* Multiple range start values */
timeline-trigger-activation-range-start:
  contain,
  entry 50%;

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

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

Values

normal

Represents the start 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-start property can be used to explicitly define the start 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-start 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 0%.

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

Specifying multiple range start values

When multiple values are specified in a single timeline-trigger-activation-range-start 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-start value is set, the timeline-trigger-activation-range-start will apply to all the timeline-trigger-names. If two timeline-trigger-activation-range-start values are set, they will cycle between the timeline-trigger-names until all of them have a timeline-trigger-activation-range-start 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-start:
  cover,
  entry 40%;

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

Formal definition

Value not found in DB!

Formal syntax

timeline-trigger-activation-range-start = 
[ 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 start 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-start of entry 50%, which sets the trigger's activation range start point to 50% through the entry range (when 50% of the tracked element has entered the viewport). The timeline-trigger-activation-range-end value defaults to 100% of the way through the cover range, meaning that the animation won't pause until the tracked element has left the viewport in either direction.
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-start: entry 50%;
}

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 50% of the tracked <div> has entered the viewport, the animation will play; when the tracked <div> has completely exited the viewport at either edge, the animation will pause.

Specifications

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

Browser compatibility

See also