| 338 | window.addEventListener('scroll', onScroll, {passive: true, capture: true}); |
| 339 | |
| 340 | function scrollToCurrentHash() { |
| 341 | if (!location.hash || location.hash === '#') { |
| 342 | return; |
| 343 | } |
| 344 | |
| 345 | let anchorId = location.hash.slice(1); |
| 346 | try { |
| 347 | anchorId = decodeURIComponent(anchorId); |
| 348 | } catch { |
| 349 | // Fall back to raw hash |
| 350 | } |
| 351 | |
| 352 | if (!anchorId) { |
| 353 | return; |
| 354 | } |
| 355 | |
| 356 | requestAnimationFrame(() => { |
| 357 | let element = document.getElementById(anchorId); |
| 358 | if (element) { |
| 359 | element.scrollIntoView(); |
| 360 | } |
| 361 | }); |
| 362 | } |
| 363 | |
| 364 | if (document.readyState === 'complete' || document.readyState === 'interactive') { |
| 365 | scrollToCurrentHash(); |