fix: liens du menu pointant vers la page d'accueil
This commit is contained in:
@@ -69,12 +69,14 @@
|
||||
themeToggle?.addEventListener('click', toggleTheme);
|
||||
})();
|
||||
|
||||
// Smooth scrolling
|
||||
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
|
||||
// Smooth scrolling (uniquement pour les ancres de la page courante)
|
||||
document.querySelectorAll('a[href*="#"]').forEach(anchor => {
|
||||
anchor.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
const target = document.querySelector(this.getAttribute('href'));
|
||||
const url = new URL(this.href, window.location.href);
|
||||
if (url.pathname !== window.location.pathname || !url.hash) return;
|
||||
const target = document.querySelector(url.hash);
|
||||
if (target) {
|
||||
e.preventDefault();
|
||||
target.scrollIntoView({
|
||||
behavior: 'smooth',
|
||||
block: 'start'
|
||||
|
||||
Reference in New Issue
Block a user