window.addEventListener('load', function(){ var menu = document.querySelector('div[data-id="5333285"]'); if (!menu) return; var placeholder = document.createElement('div'); var startY = menu.getBoundingClientRect().top + window.pageYOffset; function setPlaceholderHeight(){ placeholder.style.height = menu.getBoundingClientRect().height + 'px'; } function onScroll(){ if (window.pageYOffset > startY){ if (!menu.classList.contains('is-fixed')){ setPlaceholderHeight(); menu.parentNode.insertBefore(placeholder, menu); menu.classList.add('is-fixed'); } } else { if (menu.classList.contains('is-fixed')){ menu.classList.remove('is-fixed'); if (placeholder.parentNode) placeholder.parentNode.removeChild(placeholder); } } } window.addEventListener('scroll', onScroll, {passive:true}); window.addEventListener('resize', function(){ if (menu.classList.contains('is-fixed')) setPlaceholderHeight(); }); });

Seguridad

4 Properties
Ordenar por: