diff --git a/index.html b/index.html index 9e306fa..27c9be4 100644 --- a/index.html +++ b/index.html @@ -76,6 +76,6 @@

The trademarks REALTOR®, REALTORS®, and the REALTOR® logo are controlled by The Canadian Real Estate Association (CREA) and identify real estate professionals who are members of CREA.

Data Copyright © 2023 REALTORS® Association of Hamilton-Burlington with portions Copyright © 2023 RESO.

- + diff --git a/static/viewer.js b/static/viewer.js index d909536..efe7b0e 100644 --- a/static/viewer.js +++ b/static/viewer.js @@ -175,6 +175,8 @@ document.getElementById('downloadLink').addEventListener('click', function() { // Scroll to top button let timeout; +let isHovered = false; // flag to check if the button is being hovered over + const scrollToTopButton = document.getElementById("scrollToTopButton"); function showButton() { @@ -184,21 +186,36 @@ function showButton() { } function hideButton() { - scrollToTopButton.classList.remove('fade-in'); - scrollToTopButton.classList.add('fade-out'); - setTimeout(() => { - scrollToTopButton.style.display = 'none'; - }, 500); // match this with your CSS transition time + if (!isHovered) { + scrollToTopButton.classList.remove('fade-in'); + scrollToTopButton.classList.add('fade-out'); + setTimeout(() => { + if (!isHovered) { + scrollToTopButton.style.display = 'none'; + } + }, 500); // match this with your CSS transition time + } } window.addEventListener('scroll', function() { if (window.scrollY > 200) { showButton(); clearTimeout(timeout); - timeout = setTimeout(hideButton, 2000); // 2 seconds + timeout = setTimeout(hideButton, 3000); // 3 seconds } }); +// Handle hover state +scrollToTopButton.addEventListener('mouseenter', function() { + isHovered = true; +}); + +scrollToTopButton.addEventListener('mouseleave', function() { + isHovered = false; + hideButton(); +}); + +// Scroll to top on click scrollToTopButton.addEventListener('click', function() { window.scrollTo({ top: 0,