timeline-trigger-active-range-end CSS property
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The timeline-trigger-active-range-end CSS property specifies the end point of a scroll-triggered animation trigger's active range.
Syntax
/* Keyword or <length-percentage> */
timeline-trigger-active-range-end: auto;
timeline-trigger-active-range-end: normal;
timeline-trigger-active-range-end: 80%;
timeline-trigger-active-range-end: 400px;
/* Named timeline range value */
timeline-trigger-active-range-end: contain;
timeline-trigger-active-range-end: exit;
timeline-trigger-active-range-end: entry 100%;
timeline-trigger-active-range-end: contain 600px;
/* Multiple range end values */
timeline-trigger-active-range-end: contain, exit;
/* Global values */
timeline-trigger-active-range-end: inherit;
timeline-trigger-active-range-end: initial;
timeline-trigger-active-range-end: revert;
timeline-trigger-active-range-end: revert-layer;
timeline-trigger-active-range-end: unset;
The timeline-trigger-active-range-end property is specified as one or more values, separated by commas.
Values
auto-
The
timeline-trigger-active-range-endproperty is set to the same value as thetimeline-trigger-activation-range-endproperty. This is the default value. normal-
Represents the end of the timeline.
<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-active-range-end property can be set to explicitly define the end of the trigger's active range. Read the linked guide and the timeline-trigger-active-range description for more information.
Allowed values for the timeline-trigger-active-range-end property are:
autonormal- 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-active-range-end, along with the timeline-trigger-active-range-start property, can both be set in a single declaration using the timeline-trigger-active-range shorthand.
Specifying multiple range end values
When multiple values are specified in a single timeline-trigger-active-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-active-range-end value is set, the timeline-trigger-active-range-end will apply to all the timeline-trigger-names. If two timeline-trigger-active-range-end values are set, they will cycle between the timeline-trigger-names until all of them have a timeline-trigger-active-range-end value set. And so on.
For example, consider these declarations:
timeline-trigger-name: --my-trigger, --my-other-trigger, --another-trigger;
timeline-trigger-active-range-end: contain, exit;
In this case, the first name will use the contain range end, and the second name will use the exit range end. The third name will cycle back to using the contain range end again.
Formal definition
Value not found in DB!Formal syntax
timeline-trigger-active-range-end =
[ auto | 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 active 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.
<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-namevalue of--t, which is equal to the identifier referenced in the animated<div>'sanimation-triggerproperty value, associating the two together. - A
timeline-trigger-sourcevalue ofview(), 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-rangeofcontain 30% contain 60%, which sets the trigger's activation range to a small portion of thecontainrange. - A
timeline-trigger-active-range-endofcover 100%. Thetimeline-trigger-active-range-startvalue defaults to thetimeline-trigger-activation-range-startvalue —contain 30%— so we end up with an overalltimeline-trigger-active-rangeofcontain 30% cover 100%.
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: contain 30% contain 60%;
timeline-trigger-active-range-end: cover 100%;
}
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.
div.animated {
position: fixed;
top: 25px;
left: 25px;
}
Finally, we define the @keyframes for the rotate animation:
@keyframes rotate {
from {
rotate: 0deg;
}
to {
rotate: 360deg;
}
}
Result
The rendered result looks like this:
Try scrolling the content up. When the tracked <div> moves into the narrow activation range, the animation will start. At this point, you can scroll the tracked <div> completely off the top of the viewport before the animation will stop again. However, if after starting the animation, you start to scroll the tracked <div> downwards again, it will stop as soon as the start of the narrow activation range is reached. This is because we extended the end of the active range, but not the start.
Specifications
This feature does not appear to be defined in any specification.>Browser compatibility
See also
timeline-trigger-active-range-starttimeline-trigger-active-rangeshorthand propertytimeline-trigger-name,timeline-trigger-source, andtimeline-trigger-activation-rangetimeline-triggershorthand property- Using CSS scroll-triggered animations
- CSS animations module