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 */
timeline-trigger-active-range-end: auto;
timeline-trigger-active-range-end: normal;
/* <length-percentage> */
timeline-trigger-active-range-end: 80%;
timeline-trigger-active-range-end: 400px;
/* Named timeline range */
timeline-trigger-active-range-end: contain;
timeline-trigger-active-range-end: exit;
/* Named timeline range plus offset */
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;
Values
Specified as one or more values, separated by commas. Possible values are:
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-
Equivalent to
cover 100%for a view progress timelinetimeline-trigger-source, andscroll 100%for a scroll progress timelinetimeline-trigger-source. -
Specifies a length or percentage value measured from the beginning of the
normaltimeline. <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-active-range-end property can be set to explicitly define the end of the trigger's active range.
The default value is auto, which sets the timeline-trigger-active-range-end value to the same as the timeline-trigger-activation-range-end.
A value of 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-active-range-end property, along with the timeline-trigger-active-range-start property, can also be set using the timeline-trigger-active-range shorthand.
Specifying multiple range end values
When you specify multiple comma-separated values on a single timeline-trigger-active-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-active-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-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.
Consider these declarations:
timeline-trigger-name: --my-trigger, --my-other-trigger, --another-trigger;
timeline-trigger-active-range-end: contain, exit;
In this case, --my-trigger will use the contain range end and --my-other-trigger will use the exit 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 contain range end.
Formal definition
| Initial value | auto |
|---|---|
| Applies to | all elements |
| Inherited | no |
| Percentages | Relative to the specified named timeline range if specified, otherwise relative to the entire timeline |
| Computed value | A list where each item may be 'normal', a length percentage, or a timeline range name and a length percentage |
| Animation type | Not animatable |
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 inset the end of a scroll-triggered animation trigger's active range by setting a custom timeline-trigger-active-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.
<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.
.animated {
position: fixed;
top: 25px;
left: 25px;
}
Next, we define the @keyframes for the rotate animation we will use later:
@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.
.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-namewith value--t, which is equal to the identifier referenced in the animated<div>'sanimation-triggerproperty value, associating the two together. - A
timeline-trigger-sourcewith valueview(), 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%. When not explicitly set, 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%.
.trigger {
timeline-trigger-name: --t;
timeline-trigger-source: view();
timeline-trigger-activation-range: contain 30% contain 60%;
timeline-trigger-active-range-end: cover 100%;
}
Result
Try scrolling the content up. The animation plays when the tracked <div> moves into the narrow activation range between 30% and 60% of the way through the timeline range. At this point, you can scroll the tracked element completely off the top of the scrollport before the animation will pause again.
When you scroll downwards again, the animation will start when the tracked element reaches the 60% point, but pause as soon as the 30% point is reached. This is because we extended the end of the active range, but not the start.
Specifications
| Specification |
|---|
| Animation Triggers> # propdef-timeline-trigger-active-range-end> |
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 animation triggers module
- CSS animations module