I have implemented a pop-up overlay on my website, triggered by clicking a button. However, I am looking to enhance this functionality so that when users scroll down the webpage and then move their cursor towards the top of the page (such as the navigation bar), the pop-up window will automatically appear.
Javascript
// Setup Variables
var closePopup = document.getElementById("popupclose");
var overlay = document.getElementById("overlay");
var popup = document.getElementById("popup");
var button = document.getElementById("button");
// Close Popup Function
closePopup.onclick = function() {
overlay.style.display = 'none';
popup.style.display = 'none';
};
// Display Overlay and Pop-up
button.onclick = function() {
overlay.style.display = 'block';
popup.style.display = 'block';
}
For a demo showcasing all the code, check out my JSFiddle. https://jsfiddle.net/1ud9crou/