make nav clickable
This commit is contained in:
parent
3daecd6eea
commit
1c35e99ed2
1 changed files with 16 additions and 11 deletions
|
|
@ -933,11 +933,14 @@ 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 => {
|
document.querySelectorAll('nav a').forEach(link => {
|
||||||
link.addEventListener('click', function(e) {
|
link.addEventListener('click', function(e) {
|
||||||
|
const href = this.getAttribute('href');
|
||||||
|
// Only intercept if it's a # anchor link
|
||||||
|
if (href && href.startsWith('#')) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const targetId = this.getAttribute('href');
|
const targetId = href;
|
||||||
const targetElement = document.querySelector(targetId);
|
const targetElement = document.querySelector(targetId);
|
||||||
if (targetElement) {
|
if (targetElement) {
|
||||||
const navHeight = stickyNav.offsetHeight;
|
const navHeight = stickyNav.offsetHeight;
|
||||||
|
|
@ -947,6 +950,8 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
behavior: 'smooth'
|
behavior: 'smooth'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// If it's a regular link (like /playlists/), let it navigate normally
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue