diff --git a/public/app.js b/public/app.js index 918cf40..2e01043 100644 --- a/public/app.js +++ b/public/app.js @@ -8,6 +8,7 @@ const searchInput = document.getElementById('searchInput'); const linksContainer = document.getElementById('linksContainer'); const toastContainer = document.getElementById('toastContainer'); const archiveToggle = document.getElementById('archiveToggle'); +const scrollToTopBtn = document.getElementById('scrollToTopBtn'); // State let allLinks = []; @@ -18,6 +19,7 @@ let showArchived = false; document.addEventListener('DOMContentLoaded', () => { loadLinks(); setupEventListeners(); + setupScrollToTop(); }); // Event listeners @@ -27,6 +29,26 @@ function setupEventListeners() { archiveToggle.addEventListener('click', handleToggleArchive); } +// Setup scroll to top button +function setupScrollToTop() { + // Show/hide button based on scroll position + window.addEventListener('scroll', () => { + if (window.pageYOffset > 300) { + scrollToTopBtn.classList.add('show'); + } else { + scrollToTopBtn.classList.remove('show'); + } + }); + + // Scroll to top when button is clicked + scrollToTopBtn.addEventListener('click', () => { + window.scrollTo({ + top: 0, + behavior: 'smooth' + }); + }); +} + // Load all links async function loadLinks() { try { diff --git a/public/index.html b/public/index.html index 80bafc6..106b03a 100644 --- a/public/index.html +++ b/public/index.html @@ -75,6 +75,12 @@
+ +