From 1c35e99ed2abc9fb7369a7d1fec1c6287a2cc29f Mon Sep 17 00:00:00 2001 From: sakrecoer Date: Sun, 16 Aug 2026 15:15:41 +0200 Subject: [PATCH] make nav clickable --- themes/one-pager/assets/js/scripts.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/themes/one-pager/assets/js/scripts.js b/themes/one-pager/assets/js/scripts.js index 3e6ecd1..e6b6e5e 100644 --- a/themes/one-pager/assets/js/scripts.js +++ b/themes/one-pager/assets/js/scripts.js @@ -933,20 +933,25 @@ document.addEventListener('DOMContentLoaded', function() { }); }); - // Smooth scrolling for navigation links (both main nav and sticky nav) + // Smooth scrolling for navigation links (only for # anchors) document.querySelectorAll('nav a').forEach(link => { link.addEventListener('click', function(e) { - e.preventDefault(); - const targetId = this.getAttribute('href'); - const targetElement = document.querySelector(targetId); - if (targetElement) { - const navHeight = stickyNav.offsetHeight; - const targetPosition = targetElement.getBoundingClientRect().top + window.pageYOffset - navHeight - 20; - window.scrollTo({ - top: targetPosition, - behavior: 'smooth' - }); + const href = this.getAttribute('href'); + // Only intercept if it's a # anchor link + if (href && href.startsWith('#')) { + e.preventDefault(); + const targetId = href; + const targetElement = document.querySelector(targetId); + if (targetElement) { + const navHeight = stickyNav.offsetHeight; + const targetPosition = targetElement.getBoundingClientRect().top + window.pageYOffset - navHeight - 20; + window.scrollTo({ + top: targetPosition, + behavior: 'smooth' + }); + } } + // If it's a regular link (like /playlists/), let it navigate normally }); });