Spaces:
Sleeping
Sleeping
Update public/index.js
Browse files- public/index.js +22 -5
public/index.js
CHANGED
|
@@ -229,21 +229,38 @@ if (navMenu) {
|
|
| 229 |
|
| 230 |
document.querySelectorAll('.nav-link').forEach(link => {
|
| 231 |
link.addEventListener('click', (e) => {
|
| 232 |
-
|
|
|
|
| 233 |
closeMenu();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
}
|
| 235 |
});
|
| 236 |
});
|
| 237 |
|
| 238 |
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
|
| 239 |
anchor.addEventListener('click', function (e) {
|
|
|
|
|
|
|
|
|
|
| 240 |
e.preventDefault();
|
| 241 |
-
const target = document.querySelector(
|
| 242 |
if (target) {
|
| 243 |
-
|
| 244 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
| 246 |
-
}
|
| 247 |
}
|
| 248 |
});
|
| 249 |
});
|
|
|
|
| 229 |
|
| 230 |
document.querySelectorAll('.nav-link').forEach(link => {
|
| 231 |
link.addEventListener('click', (e) => {
|
| 232 |
+
const href = link.getAttribute('href');
|
| 233 |
+
if (href && !href.startsWith('#')) {
|
| 234 |
closeMenu();
|
| 235 |
+
} else if (href && href.startsWith('#')) {
|
| 236 |
+
e.preventDefault();
|
| 237 |
+
const target = document.querySelector(href);
|
| 238 |
+
if (target) {
|
| 239 |
+
closeMenu();
|
| 240 |
+
setTimeout(() => {
|
| 241 |
+
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
| 242 |
+
}, 400);
|
| 243 |
+
}
|
| 244 |
}
|
| 245 |
});
|
| 246 |
});
|
| 247 |
|
| 248 |
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
|
| 249 |
anchor.addEventListener('click', function (e) {
|
| 250 |
+
const href = this.getAttribute('href');
|
| 251 |
+
if (!href || href === '#') return;
|
| 252 |
+
|
| 253 |
e.preventDefault();
|
| 254 |
+
const target = document.querySelector(href);
|
| 255 |
if (target) {
|
| 256 |
+
if (navMenu && navMenu.classList.contains('active')) {
|
| 257 |
+
closeMenu();
|
| 258 |
+
setTimeout(() => {
|
| 259 |
+
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
| 260 |
+
}, 400);
|
| 261 |
+
} else {
|
| 262 |
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
| 263 |
+
}
|
| 264 |
}
|
| 265 |
});
|
| 266 |
});
|