animation-timeline: value; object.style.animationTimeline = "value"; <'animation-timeline'> = <single-animation-timeline># <single-animation-timeline> = auto | none | <custom-ident> | <scroll()> | <view()> auto Automatically specified by the user agent.
none The animation is not associated with a timeline.
<custom-ident> Specifies any valid identifier that is not misinterpreted as a keyword.
<scroll()> = scroll( [ <scroller> || <axis> ]? ) <scroller> = root | nearest | self root Specifies to use the document viewport as the scroll container.
nearest Specifies to use the nearest ancestor scroll container.
self Specifies to use the element’s own principal box as the scroll container. If the principal box is not a scroll container, then the scroll progress timeline is inactive.
<axis> = block | inline | vertical | horizontal block Specifies to use the measure of progress along the block axis of the scroll container.
inline Specifies to use the measure of progress along the inline axis of the scroll container.
vertical Specifies to use the measure of progress along the vertical axis of the scroll container.
horizontal Specifies to use the measure of progress along the horizontal axis of the scroll container.
<view()> = view( [ <axis> || <'view-timeline-inset'> ]? ) <axis> = block | inline | vertical | horizontal block Specifies to use the measure of progress along the block axis of the scroll container.
inline Specifies to use the measure of progress along the inline axis of the scroll container.
vertical Specifies to use the measure of progress along the vertical axis of the scroll container.
horizontal Specifies to use the measure of progress along the horizontal axis of the scroll container.
<'view-timeline-inset'> = [ [ auto | <length-percentage> ]{1,2} ]# auto Automatically specified by the user agent.
<length-percentage> =
<length> |
<percentage> <length> Specifies the length using a number followed by a unit of measurement.
<percentage> Specifies the percentage using a number followed by a percent sign (%).
<!doctype html>
<html>
<head>
<style>
@keyframes mykeyframes
{
0%
{
background-color: red;
}
100%
{
background-color: blue;
}
}
.myclass
{
height: 50vh;
overflow: scroll;
scroll-timeline-name: mytimeline;
width: 50vw;
}
.myclass > div
{
animation-duration: 1s;
animation-name: mykeyframes;
animation-timeline: none;
height: 100vh;
width: 100vw;
}
</style>
</head>
<body>
<div class="myclass">
<div>none</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
@keyframes mykeyframes
{
0%
{
background-color: red;
}
100%
{
background-color: blue;
}
}
.myclass
{
height: 50vh;
overflow: scroll;
scroll-timeline-name: mytimeline;
width: 50vw;
}
.myclass > div
{
animation-duration: 1s;
animation-name: mykeyframes;
animation-timeline: mytimeline;
height: 100vh;
width: 100vw;
}
</style>
</head>
<body>
<div class="myclass">
<div>custom-ident</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
@keyframes mykeyframes
{
0%
{
background-color: red;
}
100%
{
background-color: blue;
}
}
.myclass
{
height: 50vh;
overflow: scroll;
scroll-timeline-name: mytimeline;
width: 50vw;
}
.myclass > div
{
animation-duration: 1s;
animation-name: mykeyframes;
animation-timeline: scroll(root);
height: 100vh;
width: 100vw;
}
</style>
</head>
<body>
<div class="myclass">
<div>root</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
@keyframes mykeyframes
{
0%
{
background-color: red;
}
100%
{
background-color: blue;
}
}
.myclass
{
height: 50vh;
overflow: scroll;
scroll-timeline-name: mytimeline;
width: 50vw;
}
.myclass > div
{
animation-duration: 1s;
animation-name: mykeyframes;
animation-timeline: scroll(nearest);
height: 100vh;
width: 100vw;
}
</style>
</head>
<body>
<div class="myclass">
<div>nearest</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
@keyframes mykeyframes
{
0%
{
background-color: red;
}
100%
{
background-color: blue;
}
}
.myclass
{
height: 50vh;
overflow: scroll;
scroll-timeline-name: mytimeline;
width: 50vw;
}
.myclass > div
{
animation-duration: 1s;
animation-name: mykeyframes;
animation-timeline: scroll(self);
height: 100vh;
width: 100vw;
}
</style>
</head>
<body>
<div class="myclass">
<div>self</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
@keyframes mykeyframes
{
0%
{
background-color: red;
}
100%
{
background-color: blue;
}
}
.myclass
{
height: 50vh;
overflow: scroll;
scroll-timeline-name: mytimeline;
width: 50vw;
}
.myclass > div
{
animation-duration: 1s;
animation-name: mykeyframes;
animation-timeline: scroll(block);
height: 100vh;
width: 100vw;
}
</style>
</head>
<body>
<div class="myclass">
<div>block</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
@keyframes mykeyframes
{
0%
{
background-color: red;
}
100%
{
background-color: blue;
}
}
.myclass
{
height: 50vh;
overflow: scroll;
scroll-timeline-name: mytimeline;
width: 50vw;
}
.myclass > div
{
animation-duration: 1s;
animation-name: mykeyframes;
animation-timeline: scroll(inline);
height: 100vh;
width: 100vw;
}
</style>
</head>
<body>
<div class="myclass">
<div>inline</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
@keyframes mykeyframes
{
0%
{
background-color: red;
}
100%
{
background-color: blue;
}
}
.myclass
{
height: 50vh;
overflow: scroll;
scroll-timeline-name: mytimeline;
width: 50vw;
}
.myclass > div
{
animation-duration: 1s;
animation-name: mykeyframes;
animation-timeline: scroll(vertical);
height: 100vh;
width: 100vw;
}
</style>
</head>
<body>
<div class="myclass">
<div>vertical</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
@keyframes mykeyframes
{
0%
{
background-color: red;
}
100%
{
background-color: blue;
}
}
.myclass
{
height: 50vh;
overflow: scroll;
scroll-timeline-name: mytimeline;
width: 50vw;
}
.myclass > div
{
animation-duration: 1s;
animation-name: mykeyframes;
animation-timeline: scroll(horizontal);
height: 100vh;
width: 100vw;
}
</style>
</head>
<body>
<div class="myclass">
<div>horizontal</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
@keyframes mykeyframes
{
0%
{
background-color: red;
}
100%
{
background-color: blue;
}
}
.myclass
{
height: 50vh;
overflow: scroll;
scroll-timeline-name: mytimeline;
width: 50vw;
}
.myclass > div
{
animation-duration: 1s;
animation-name: mykeyframes;
animation-timeline: view(block);
height: 100vh;
width: 100vw;
}
</style>
</head>
<body>
<div class="myclass">
<div>block</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
@keyframes mykeyframes
{
0%
{
background-color: red;
}
100%
{
background-color: blue;
}
}
.myclass
{
height: 50vh;
overflow: scroll;
scroll-timeline-name: mytimeline;
width: 50vw;
}
.myclass > div
{
animation-duration: 1s;
animation-name: mykeyframes;
animation-timeline: view(inline);
height: 100vh;
width: 100vw;
}
</style>
</head>
<body>
<div class="myclass">
<div>inline</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
@keyframes mykeyframes
{
0%
{
background-color: red;
}
100%
{
background-color: blue;
}
}
.myclass
{
height: 50vh;
overflow: scroll;
scroll-timeline-name: mytimeline;
width: 50vw;
}
.myclass > div
{
animation-duration: 1s;
animation-name: mykeyframes;
animation-timeline: view(vertical);
height: 100vh;
width: 100vw;
}
</style>
</head>
<body>
<div class="myclass">
<div>vertical</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
@keyframes mykeyframes
{
0%
{
background-color: red;
}
100%
{
background-color: blue;
}
}
.myclass
{
height: 50vh;
overflow: scroll;
scroll-timeline-name: mytimeline;
width: 50vw;
}
.myclass > div
{
animation-duration: 1s;
animation-name: mykeyframes;
animation-timeline: view(horizontal);
height: 100vh;
width: 100vw;
}
</style>
</head>
<body>
<div class="myclass">
<div>horizontal</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
@keyframes mykeyframes
{
0%
{
background-color: red;
}
100%
{
background-color: blue;
}
}
.myclass
{
height: 50vh;
overflow: scroll;
scroll-timeline-name: mytimeline;
width: 50vw;
}
.myclass > div
{
animation-duration: 1s;
animation-name: mykeyframes;
animation-timeline: view(auto);
height: 100vh;
width: 100vw;
}
</style>
</head>
<body>
<div class="myclass">
<div>auto</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
@keyframes mykeyframes
{
0%
{
background-color: red;
}
100%
{
background-color: blue;
}
}
.myclass
{
height: 50vh;
overflow: scroll;
scroll-timeline-name: mytimeline;
width: 50vw;
}
.myclass > div
{
animation-duration: 1s;
animation-name: mykeyframes;
animation-timeline: view(100px);
height: 100vh;
width: 100vw;
}
</style>
</head>
<body>
<div class="myclass">
<div>length-percentage</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
@keyframes mykeyframes
{
0%
{
background-color: red;
}
100%
{
background-color: blue;
}
}
.myclass
{
height: 50vh;
overflow: scroll;
scroll-timeline-name: mytimeline;
width: 50vw;
}
.myclass > div
{
animation-duration: 1s;
animation-name: mykeyframes;
height: 100vh;
width: 100vw;
}
</style>
</head>
<body>
<button>initial</button>
<button>auto</button>
<button>none</button>
<button value="mytimeline">custom-ident</button><br>
<button>scroll(root)</button>
<button>scroll(nearest)</button>
<button>scroll(self)</button><br>
<button>scroll(block)</button>
<button>scroll(inline)</button>
<button>scroll(vertical)</button>
<button>scroll(horizontal)</button><br>
<button>view(block)</button>
<button>view(inline)</button>
<button>view(vertical)</button>
<button>view(horizontal)</button><br>
<button>view(auto)</button>
<button value="view(100px)">view(length-percentage)</button>
<div class="myclass">
<div>animation-timeline</div>
</div>
<script>
function myfunction(myparameter)
{
const mytarget = myparameter.target;
const myproperty = mytarget.value || mytarget.innerHTML;
document.querySelector(".myclass > div").style.animationTimeline = myproperty;
}
for(const mybutton of document.querySelectorAll("button"))
{
mybutton.addEventListener("mouseover", myfunction);
}
</script>
</body>
</html>