view-timeline-root-source.html (1423B)
1 <!DOCTYPE html> 2 <html id="top"> 3 <meta charset="utf-8"> 4 <title>View timeline delay</title> 5 <link rel="help" href="https://drafts.csswg.org/scroll-animations-1/#viewtimeline-interface"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="/web-animations/testcommon.js"></script> 9 <script src="/scroll-animations/scroll-timelines/testcommon.js"></script> 10 <script src="/scroll-animations/view-timelines/testcommon.js"></script> 11 <style> 12 #target { 13 margin: 200vh; 14 background-color: green; 15 height: 100px; 16 width: 100px; 17 } 18 </style> 19 <body> 20 <div id="target"></div> 21 </body> 22 <script type="text/javascript"> 23 promise_test(async t => { 24 const timeline = new ViewTimeline({ subject: target }); 25 const anim = target.animate({ opacity: [0, 1 ] }, 26 { timeline: timeline, 27 rangeStart: "entry 0%", 28 rangeEnd: "entry 100%", 29 fill: "both" }); 30 const scroller = document.scrollingElement; 31 const scrollRange = scroller.scrollHeight - scroller.clientHeight; 32 33 await anim.ready; 34 35 await waitForNextFrame(); 36 scroller.scrollTop = scrollRange / 2; 37 await waitForNextFrame(); 38 39 assert_equals(getComputedStyle(target).opacity, "1"); 40 }, 'Test view-timeline with document scrolling element.'); 41 </script>