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 of a scroll-triggered animation trigger's activation range.
Syntax
/* 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 with <length-percentage> */
timeline-trigger-activation-range-start: entry 40%;
timeline-trigger-activation-range-start: contain -20px;
/* Multiple range start values */
timeline-trigger-activation-range-start:
contain,
entry -10%;
/* 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
This property is specified as a comma-separated list of the following values:
normal-
The default value. Equivalent to
cover 0%for a view progress timelinetimeline-trigger-source, andscroll 0%for a scroll progress timeline. <length-percentage>-
Specifies an offset as a
<length>or<percentage>, measured from the beginning of thenormaltimeline. Percentages are relative to the length of thenormaltimeline range. <timeline-range-name>-
Specifies the start (
0%) of thecover,contain,entry,exit,entry-crossing,exit-crossing, orscrolltimeline range. <timeline-range-name><length-percentage>-
Specifies a length or percentage offset measured from the beginning of the specified named timeline range. Percentages are relative to the length of the named timeline.
Description
The timeline-trigger-activation-range-start property can be used to explicitly specify the start of a trigger's activation range. The value is specified as a timeline range, offset, or both.
A trigger's activation range is the range along the associated scrollport within which a CSS scroll-triggered animation trigger will activate. Activation occurs when the tracked element enters the activation range, and deactivation occurs when it leaves the active range.
The normal value sets the start of the activation range to the start of the default named range. This is equivalent to cover 0% for a view progress timeline and scroll 0% for a scroll progress timeline.
Other timeline-trigger-activation-range-start property can be used to set:
- An offset from the
normalrange -
A
<length>or<percentage>value specifies an offset from the beginning of thenormaltimeline, which again defaults tocover 0%for a view progress timeline source, andscroll 0%for a scroll progress timeline source. Negative values outset the start, resulting in a longer activation range. Positive values inset the start, making the activation range shorter. - The start of a specific named range
-
A
<timeline-range-name>value specifies a0%offset along the named timeline range, which is eithercover,contain,entry,exit,entry-crossing,exit-crossing, orscroll. See Understanding timeline range names. - An offset from a specific named range
-
When both a
<timeline-range-name>and<length>or<percentage>value are specified, the start is the beginning of the named range offset by the distance specified. Percentage values are relative to the length of the range specified. See Setting insets using percentages.
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, which in turn can be set using the timeline-trigger shorthand.
Specifying multiple range start values
When multiple values are specified in a comma-separated timeline-trigger-activation-range-start declaration, each value applies to a timeline trigger in the order in which the names appear in the timeline-trigger-name property. 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:
- If the number of
timeline-trigger-activation-range-startvalues exceeds the number oftimeline-trigger-namevalues, the excess range values are discarded. - If the number of trigger names is greater than the number of ranges, the
timeline-trigger-activation-range-startvalues are cycled until everytimeline-trigger-namevalue has atimeline-trigger-activation-range-startvalue set. - If multiple
timeline-trigger-namevalues are set, but only onetimeline-trigger-activation-range-startvalue is set, thattimeline-trigger-activation-range-startvalue will apply to all thetimeline-trigger-names.
Formal definition
| Initial value | normal |
|---|---|
| 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-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 to create a trigger on — 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 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 a rotate animation:
@keyframes rotate {
from {
rotate: 0deg;
}
to {
rotate: 360deg;
}
}
Using the animation shorthand, the rotate animation is applied to the .animated element. 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 element creates the .animated element's trigger via the following properties:
- A
timeline-trigger-namewith value--t, which is equal to the identifier referenced in the.animatedelement'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-range-startofentry 50%. Theentryrange spans from when the trigger element first starts entering the scrollport to when it has completely entered the scrollport. This value sets the trigger's activation range's start to50%through theentryrange, which occurs when50%of the tracked.triggerelement has entered the scrollport via the scrollport's end edge.
.trigger {
timeline-trigger-name: --t;
timeline-trigger-source: view();
timeline-trigger-activation-range-start: entry 50%;
}
When not explicitly set, the timeline-trigger-activation-range-end value defaults to normal, which in this case is cover 100%. The timeline-trigger-active-range-end value defaults to auto — the same as timeline-trigger-activation-range-end. This means that deactivation occurs at the end of the cover range, when the tracked element exits the scrollport's start edge.
Result
Try scrolling the content up. The animation starts playing when 50% of the tracked .trigger element 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 reverses — the animation restarts playing when the trigger element starts to enter the top of the scrollport, and pauses again when 50% of the trigger element has exited the bottom.
Specifications
| Specification |
|---|
| Animation Triggers> # propdef-timeline-trigger-activation-range-start> |
Browser compatibility
See also
timeline-trigger-activation-range-endtimeline-trigger-activation-rangeshorthand propertytimeline-trigger-name,timeline-trigger-source, andtimeline-trigger-active-rangetimeline-triggershorthand property- Using CSS scroll-triggered animations
- CSS animation triggers module
- CSS animations module