Skip to content

Commit de5cb94

Browse files
committed
menu visible on ancrage
1 parent a9a3bdc commit de5cb94

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

assets/js/documentation.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,4 +477,37 @@ function addScrollTopBehavior() {
477477
// no-op
478478
}
479479
}
480+
481+
function forceTopbarVisibleAtCurrentPosition() {
482+
accum = 0;
483+
dirSign = 0;
484+
lastVisible = true;
485+
setTopbarVisible(true);
486+
setHeaderVisible(true);
487+
lastScrollY = window.scrollY || window.pageYOffset || 0;
488+
}
489+
490+
document.addEventListener('click', function (e) {
491+
var el = e.target;
492+
if (!el) return;
493+
if (el.closest) {
494+
el = el.closest('a');
495+
} else if (!el.tagName || el.tagName.toLowerCase() !== 'a') {
496+
return;
497+
}
498+
if (!el) return;
499+
var href = el.getAttribute('href') || '';
500+
if (!href) return;
501+
if (href.charAt(0) === '#') {
502+
setTimeout(forceTopbarVisibleAtCurrentPosition, 80);
503+
return;
504+
}
505+
try {
506+
var url = new URL(href, window.location.href);
507+
if (url.hash && url.pathname === window.location.pathname && url.origin === window.location.origin) {
508+
setTimeout(forceTopbarVisibleAtCurrentPosition, 80);
509+
}
510+
} catch (err) {
511+
}
512+
}, true);
480513
}

0 commit comments

Comments
 (0)