//javascript for navigation bar effects on scroll window.addEventListener("scroll", function(){ const header = document.querySelector("header"); header.classList.toggle('sticky', window.scrollY > 0); }); //javascript for responsive navigation sidebar menu const menuBtn = document.querySelector(".menu-btn"); const navigation = document.querySelector(".navigation"); const navigationItems = document.querySelectorAll(".navigation a") menuBtn.addEventListener("click", () => { menuBtn.classList.toggle("active"); navigation.classList.toggle("active"); }); navigationItems.forEach((navigationItem) => { navigationItem.addEventListener("click", () => { menuBtn.classList.remove("active"); navigation.classList.remove("active"); }); }); //javascript for scroll to top button const scrollBtn = document.querySelector(".scrollToTop-btn"); window.addEventListener("scroll", function(){ scrollBtn.classList.toggle("active", window.scrollY > 500); }); //javascript for scroll back to top on click scroll-to-top button scrollBtn.addEventListener("click", () => { document.body.scrollTop = 0; document.documentElement.scrollTop = 0; }); //javascript for reveal website elements on scroll window.addEventListener("scroll", reveal); function reveal(){ var reveals = document.querySelectorAll(".reveal"); for(var i = 0; i < reveals.length; i++){ var windowHeight = window.innerHeight; var revealTop = reveals[i].getBoundingClientRect().top; var revealPoint = 50; if(revealTop < windowHeight - revealPoint){ reveals[i].classList.add("active"); } } } //popup code const popupScreen = document.querySelector(".popup-screen"); const popupBox = document.querySelector(".popup-box"); const closeBtn = document.querySelector(".close-btn"); window.addEventListener("load", () => { setTimeout(() => { popupScreen.classList.add("active"); }, 2000); //Popup the screen in 02 seconds after the page is loaded. }); closeBtn.addEventListener("click", () => { popupScreen.classList.remove("active"); //Close the popup screen on click the close button. //Create a cookie for a day (to expire within a day) on click the close button. document.cookie = "WebsiteName=testWebsite; max-age=" + 24 * 60 * 60; //1 day = 24 hours = 24*60*60 }); //Use the created cookie to hide or show the popup screen. const WebsiteCookie = document.cookie.indexOf("WebsiteName="); if(WebsiteCookie != -1){ popupScreen.style.display = "none"; //Hide the popup screen if the cookie is not expired. } else{ popupScreen.style.display = "flex"; //Show the popup screen if the cookie is expired. } //popup code close //