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

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

/* Named timeline range */
timeline-trigger-activation-range-start: cover;
timeline-trigger-activation-range-start: exit;

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

Values

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

normal

The default value. Equivalent to cover 0% for a view progress timeline timeline-trigger-source, and scroll 0% 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 start (0%) 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-start property can be used to explicitly define the start of the trigger's activation range.

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

If the <timeline-range-name> value does not include a <length-percentage>, it defaults to 0% 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-start property, along with the timeline-trigger-activation-range-end property, can also be set using the timeline-trigger-activation-range shorthand.

Specifying multiple range start values

When you specify multiple comma-separated values on a single timeline-trigger-activation-range-start 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-start 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-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.

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

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-start = 
[ normal | <length-percentage> | <timeline-range-name> <length-percentage>? ]#

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

Examples

Basic usage

In this example, we inset the start of a scroll-triggered animation trigger's activation range by setting a custom timeline-trigger-activation-range-start 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-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 scrollport via the scrollport's end edge). Whem not explicitly set, the timeline-trigger-activation-range-end value defaults to normal, which in this case is 100% of the way through the cover range, meaning that on deactivation, the animation will pause when the tracked element exits the scrollport's start edge.
css
.trigger {
  timeline-trigger-name: --t;
  timeline-trigger-source: view();
  timeline-trigger-activation-range-start: entry 50%;
}

Result

Try scrolling the content up. The animation plays when 50% of the tracked <div> has entered the scrollport end edge and pauses when it has completely exited the scrollport at the opposite edge. When you scroll down, the effect happens in reverse — the animation plays when it starts to enter the top of the scrollport, and pauses when 50% of it has exited the bottom.

Specifications

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

Browser compatibility

See also