<!DOCTYPE html><title>The animation-timeline: scroll() notation</title><metaname="viewport"content="width=device-width,initial-scale=1,minimum-scale=1"><linkrel="help"src="https://drafts.csswg.org/scroll-animations-1/rewrite#scroll-notation"><linkrel="help"src="https://github.com/w3c/csswg-drafts/issues/6674"><scriptsrc="/resources/testharness.js"></script><scriptsrc="/resources/testharnessreport.js"></script><scriptsrc="/web-animations/testcommon.js"></script><scriptsrc="support/testcommon.js"></script><style>@keyframesanim{from{translate:50px;}to{translate:150px;}}html{min-height:100vh;/* This makes the max scrollable ragne be 100px in root element */padding-bottom:100px;}#container{width:300px;height:300px;overflow:scroll;}#target{width:100px;/* This makes the max scrollable ragne be 100px in the block direction */height:100px;}/* large block content */.block-content{block-size:100%;}/* large inline content */.inline-content{inline-size:100%;block-size:5px;/* This makes the max scrollable ragne be 100px in the inline direction */padding-inline-end:100px;}</style><body><divid="log"></div><script>"use strict";setup(assert_implements_animation_timeline);constroot=document.scrollingElement;constcreateTargetWithStuff=function(t,contentClass){letcontainer=document.createElement('div');container.id='container';lettarget=document.createElement('div');target.id='target';letcontent=document.createElement('div');content.className=contentClass;// <div id='container'>// <div id='target'></div>// <div class=contentClass></div>// </div>document.body.appendChild(container);container.appendChild(target);container.appendChild(content);if(t&&typeoft.add_cleanup==='function'){t.add_cleanup(()=>{content.remove();target.remove();container.remove();});}return[container,target];};asyncfunctionscrollLeft(element,value){element.scrollLeft=value;awaitwaitForNextFrame();}asyncfunctionscrollTop(element,value){element.scrollTop=value;awaitwaitForNextFrame();}promise_test(asynct=>{let[container,div]=createTargetWithStuff(t,'block-content');awaitrunAndWaitForFrameUpdate(()=>{div.style.animation="anim 10s linear";div.style.animationTimeline="scroll(nearest)";});awaitscrollTop(root,50);assert_equals(getComputedStyle(div).translate,'50px');awaitscrollTop(container,50);assert_equals(getComputedStyle(div).translate,'100px');awaitscrollTop(root,0);},'animation-timeline: scroll(nearest)');promise_test(asynct=>{let[container,div]=createTargetWithStuff(t,'block-content');awaitrunAndWaitForFrameUpdate(()=>{div.style.animation="anim 10s linear";div.style.animationTimeline="scroll(root)";});awaitscrollTop(container,50);assert_equals(getComputedStyle(div).translate,'50px');awaitscrollTop(root,50);assert_equals(getComputedStyle(div).translate,'100px');awaitscrollTop(root,0);},'animation-timeline: scroll(root)');promise_test(asynct=>{let[container,div]=createTargetWithStuff(t,'block-content');awaitrunAndWaitForFrameUpdate(()=>{container.style.animation="anim 10s linear";container.style.animationTimeline="scroll(self)";});awaitscrollTop(container,50);assert_equals(getComputedStyle(container).translate,'100px');},'animation-timeline: scroll(self)');promise_test(asynct=>{let[container,div]=createTargetWithStuff(t,'block-content');awaitrunAndWaitForFrameUpdate(()=>{div.style.animation="anim 10s linear";div.style.animationTimeline="scroll(self)";});awaitscrollTop(container,50);assert_equals(getComputedStyle(div).translate,'none');},'animation-timeline: scroll(self), on non-scroller');promise_test(asynct=>{let[container,div]=createTargetWithStuff(t,'inline-content');awaitrunAndWaitForFrameUpdate(()=>{div.style.animation="anim 10s linear";div.style.animationTimeline="scroll(inline)";});awaitscrollLeft(container,50);assert_equals(getComputedStyle(div).translate,'100px');},'animation-timeline: scroll(inline)');promise_test(asynct=>{let[container,div]=createTargetWithStuff(t,'block-content');awaitrunAndWaitForFrameUpdate(()=>{container.style.writingMode='vertical-lr';div.style.animation="anim 10s linear";div.style.animationTimeline="scroll(x)";});awaitscrollLeft(container,50);assert_equals(getComputedStyle(div).translate,'100px');},'animation-timeline: scroll(x)');promise_test(asynct=>{let[container,div]=createTargetWithStuff(t,'inline-content');awaitrunAndWaitForFrameUpdate(()=>{container.style.writingMode='vertical-lr';div.style.animation="anim 10s linear";div.style.animationTimeline="scroll(y)";});awaitscrollTop(container,50);assert_equals(getComputedStyle(div).translate,'100px');},'animation-timeline: scroll(y)');// TODO: Add more tests which change the overflow property of the container for// scroll(nearest)</script></body>