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