1(function () { 2 var btn = document.getElementById('scroll-top'); 3 if (!btn) return; 4 var lastY = window.scrollY; 5 var ticking = false; 6 var hideTimer; 7 8 function show() { 9 clearTimeout(hideTimer); 10 if (btn.hasAttribute('hidden')) { 11 btn.removeAttribute('hidden'); 12 requestAnimationFrame(function () { btn.classList.add('in'); }); 13 } 14 } 15 16 function hide() { 17 if (!btn.hasAttribute('hidden') && btn.classList.contains('in')) { 18 btn.classList.remove('in'); 19 clearTimeout(hideTimer); 20 hideTimer = setTimeout(function () { btn.setAttribute('hidden', ''); }, 200); 21 } 22 } 23 24 function update() { 25 ticking = false; 26 var y = window.scrollY; 27 var up = y < lastY - 2; 28 var down = y > lastY + 2; 29 lastY = y; 30 if (up && y > 600) show(); 31 else if (down || y <= 600) hide(); 32 } 33 34 function onScroll() { 35 if (!ticking) { ticking = true; requestAnimationFrame(update); } 36 } 37 38 window.addEventListener('scroll', onScroll, { passive: true }); 39 btn.addEventListener('click', function () { 40 var reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches; 41 window.scrollTo({ top: 0, behavior: reduce ? 'auto' : 'smooth' }); 42 }); 43})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.