Fix for scroll to subsection bug on docsify (#31)
This commit is contained in:
Родитель
d88167d7c4
Коммит
e9ac42bfd3
|
@ -65,6 +65,29 @@
|
|||
<script src="//cdn.jsdelivr.net/npm/docsify@4.12.2"></script>
|
||||
-->
|
||||
|
||||
<!-- Hacky fix for scroll to subsection bug on docsify https://github.com/docsifyjs/docsify/issues/351-->
|
||||
<script>
|
||||
(function () {
|
||||
function create() {
|
||||
return function scrollDelay(hook) {
|
||||
var TARGET_QUERY = 'id';
|
||||
var SCROLL_DELAY = 10;
|
||||
|
||||
hook.doneEach(function () {
|
||||
if (!location.hash.includes('?')) return;
|
||||
let searchParams = new URLSearchParams(location.hash.split('?')[1]);
|
||||
let header = document.querySelector('#' + searchParams.get(TARGET_QUERY));
|
||||
header && setTimeout(() => header.scrollIntoView(), SCROLL_DELAY);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof $docsify === 'object') {
|
||||
$docsify.plugins = [].concat(create(), $docsify.plugins);
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
||||
<!-- Clarity -->
|
||||
<script type="text/javascript">
|
||||
(function(c,l,a,r,i,t,y){
|
||||
|
|
Загрузка…
Ссылка в новой задаче