scroll-timeline-frame-size-changed-ref.html (614B)
1 <!DOCTYPE html> 2 <title>Reference for the default scroll() timeline</title> 3 <style> 4 html { 5 min-height: 100%; 6 padding-bottom: 50px; 7 } 8 9 #box { 10 width: 100px; 11 height: 100px; 12 background-color: green; 13 transform: translateY(100px); 14 } 15 16 * { 17 margin-top: 0px; 18 margin-bottom: 0px; 19 } 20 </style> 21 22 <div id="box"></div> 23 24 <script> 25 window.addEventListener('load', function() { 26 // Move the scroller to halfway. 27 const scroller = document.scrollingElement; 28 const maxScroll = scroller.scrollHeight - scroller.clientHeight; 29 scroller.scrollTop = 0.5 * maxScroll; 30 }); 31 </script>