Skip to content

Commit 17990fd

Browse files
committed
fix pageload scroll
1 parent 19b6f68 commit 17990fd

2 files changed

Lines changed: 1 addition & 29 deletions

File tree

docs/index.html

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,34 +55,6 @@
5555
hook.afterEach(function (html) {
5656
return html + footer;
5757
});
58-
59-
hook.ready(function () {
60-
// true = show debug log
61-
let dd = false;
62-
let TARGET_QUERY = 'id';
63-
let SCROLL_DELAY = 2000; // in milisecond
64-
let location = window.location;
65-
66-
dd && console.log('custom scroll plugin called!');
67-
let currentUrlWithoutHash = new URL(
68-
location.origin + location.pathname + location.search + location.hash.substring(1)
69-
);
70-
let urlQueryParam = currentUrlWithoutHash.searchParams;
71-
let isUrlHasIdQuery = urlQueryParam.has(TARGET_QUERY);
72-
if (isUrlHasIdQuery) {
73-
dd && console.log('url has id, will scroll to element');
74-
let urlId = urlQueryParam.get(TARGET_QUERY);
75-
// run delayed, to make sure everything loaded
76-
setTimeout(function () {
77-
dd && console.log('will scroll now!');
78-
try {
79-
document.querySelector('#' + urlId).scrollIntoView();
80-
} catch (e) {
81-
dd && console.log('custom scroll failed', e);
82-
}
83-
}, SCROLL_DELAY);
84-
}
85-
});
8658
},
8759
],
8860
};

docs/script/docsify-fix-pageload-scroll.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
function create() {
33
return (hook) => {
44
const TARGET_QUERY = 'id';
5-
const SCROLL_DELAY = 500;
5+
const SCROLL_DELAY = 650;
66

77
hook.ready(function () {
88
if (!location.hash.includes('?')) return;

0 commit comments

Comments
 (0)