scroll-timeline-default.html (1542B)
1 <!DOCTYPE HTML> 2 <html class="reftest-wait"> 3 <title>The default scroll() timeline</title> 4 <link rel="help" href="https://drafts.csswg.org/scroll-animations-1/#scroll-notation"> 5 <link rel="help" href="https://drafts.csswg.org/css-animations-2/#animation-timeline"> 6 <meta name="assert" content="CSS animation correctly updates values when using the default scroll() timeline"> 7 <link rel="match" href="scroll-timeline-default-ref.html"> 8 9 <style> 10 @keyframes update { 11 from { transform: translateY(0px); } 12 to { transform: translateY(200px); } 13 } 14 15 html { 16 min-height: 100%; 17 padding-bottom: 100px; 18 } 19 20 #box { 21 width: 100px; 22 height: 100px; 23 background-color: green; 24 animation: update 1s linear; 25 animation-timeline: scroll(); 26 } 27 28 #covered { 29 width: 100px; 30 height: 100px; 31 background-color: red; 32 } 33 34 * { 35 margin-top: 0px; 36 margin-bottom: 0px; 37 } 38 </style> 39 40 <div id="box"></div> 41 <div id="covered"></div> 42 43 <script src="/web-animations/testcommon.js"></script> 44 <script> 45 document.documentElement.addEventListener('TestRendered', async () => { 46 runTest(); 47 }, { once: true }); 48 49 async function runTest() { 50 const scroller = document.scrollingElement; 51 52 await waitForCompositorReady(); 53 54 // Move the scroller to the halfway point. 55 const maxScroll = scroller.scrollHeight - scroller.clientHeight; 56 scroller.scrollTop = 0.5 * maxScroll; 57 58 await waitForNextFrame(); 59 await waitForNextFrame(); 60 61 document.documentElement.classList.remove("reftest-wait"); 62 } 63 </script>