window.addEventListener('load', function () { var loader = document.getElementById('page-loader'); if (loader) { loader.style.opacity = '0'; loader.style.transition = 'opacity 0.4s ease'; setTimeout(function () { loader.style.display = 'none'; }, 400); } }); /* document.addEventListener('DOMContentLoaded', function () { var ctaButton = document.querySelector('.cta-button'); function toggleButton() { var scrollPosition = window.scrollY; if (scrollPosition > 300) { ctaButton.style.display = 'block'; } else { ctaButton.style.display = 'none'; } } ctaButton.style.display = 'none'; window.addEventListener('scroll', toggleButton); toggleButton(); }); */ // ===== Scroll to Top ==== $(window).scroll(function() { if ($(this).scrollTop() >= 50) { // If page is scrolled more than 50px $('#return-to-top').fadeIn(200); // Fade in the arrow } else { $('#return-to-top').fadeOut(200); // Else fade out the arrow } }); $('#return-to-top').click(function() { // When arrow is clicked $('body,html').animate({ scrollTop : 0 // Scroll to top of body }, 500); });