// En el archivo de tu tema o en un bloque HTML personalizado
// Pega esto en el footer de tu sitio (antes de )
add_action('wp_footer', function() {
?>
document.addEventListener('DOMContentLoaded', function() {
const contactBar = document.getElementById('mobile-contact-bar');
if (!contactBar) return; // Seguridad por si no existe el elemento
let lastScrollY = window.scrollY;
let ticking = false;
function toggleContactBar() {
const currentScrollY = window.scrollY;
// Mostrar si sube y ya no está en el top, ocultar si baja
if (currentScrollY < lastScrollY && currentScrollY > 50) {
contactBar.style.display = 'block';
contactBar.classList.add('visible');
} else {
contactBar.style.display = 'none';
contactBar.classList.remove('visible');
}
lastScrollY = currentScrollY;
ticking = false;
}
function onScroll() {
if (!ticking) {
window.requestAnimationFrame(toggleContactBar);
ticking = true;
}
}
// Ocultar inicialmente por seguridad
contactBar.style.display = 'none';
// Listener optimizado con passive
window.addEventListener('scroll', onScroll, { passive: true });
});