1/*! 2 * Scroll to Top Button 3 * Only active on mobile (<768px) 4 */ 5 6(function() { 7 'use strict'; 8 9 // Solo ejecutar en mobile 10 function isMobile() { 11 return window.innerWidth <= 767; 12 } 13 14 if (!isMobile()) { 15 return; 16 } 17 18 // Crear botón 19 const scrollButton = document.createElement('button'); 20 scrollButton.id = 'scroll-to-top'; 21 scrollButton.innerHTML = 'â'; 22 scrollButton.setAttribute('aria-label', 'Volver arriba'); 23 scrollButton.style.display = 'none'; 24 25 // Agregar al body cuando el DOM esté listo 26 if (document.readyState === 'loading') { 27 document.addEventListener('DOMContentLoaded', function() { 28 document.body.appendChild(scrollButton); 29 }); 30 } else { 31 document.body.appendChild(scrollButton); 32 } 33 34 // Mostrar/ocultar botón al hacer scroll 35 let scrollTimeout; 36 window.addEventListener('scroll', function() { 37 clearTimeout(scrollTimeout); 38 39 if (window.pageYOffset > 300) { 40 scrollButton.style.display = 'flex'; 41 } else { 42 scrollButton.style.display = 'none'; 43 } 44 }); 45 46 // Scroll suave al hacer click 47 scrollButton.addEventListener('click', function() { 48 window.scrollTo({ 49 top: 0, 50 behavior: 'smooth' 51 }); 52 }); 53 54 // Ocultar botón si se redimensiona a desktop 55 window.addEventListener('resize', function() { 56 if (!isMobile()) { 57 scrollButton.style.display = 'none'; 58 } 59 }); 60 61})();
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.