Skip to content

Commit b9df267

Browse files
committed
disable eslint about no-async-operation
I'm not sure if there is a suitable workaround, but I don't really care.
1 parent 48310da commit b9df267

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/theme/pagetoc.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const listenActive = () => {
88
[...elems].forEach((el) => el.classList.remove("active"));
99
el.classList.add("active");
1010
// Prevent scroll updates for a short period
11+
// eslint-disable-next-line no-async-operation
1112
scrollTimeout = setTimeout(() => {
1213
scrollTimeout = null;
1314
}, 100); // Adjust timing as needed
@@ -45,9 +46,7 @@ const updateFunction = () => {
4546
const scrolledY = window.scrollY;
4647

4748
// Find the last header that is above the current scroll position
48-
let headerOffsets = headers.filter((el) => {
49-
return scrolledY >= el.offsetTop;
50-
});
49+
let headerOffsets = headers.filter((el) => scrolledY >= el.offsetTop);
5150
const lastHeader = headerOffsets.reverse().shift();
5251

5352
const pagetocLinks = [...document.querySelector(".pagetoc").children];
@@ -61,9 +60,8 @@ const updateFunction = () => {
6160
}
6261
};
6362

64-
window.addEventListener("load", () => {
63+
const onLoad = () => {
6564
const pagetoc = getPagetoc();
66-
console.log(pagetoc);
6765
var headers = [...document.getElementsByClassName("header")];
6866
headers.shift();
6967
headers.forEach((header) => {
@@ -77,4 +75,6 @@ window.addEventListener("load", () => {
7775
updateFunction();
7876
listenActive();
7977
window.addEventListener("scroll", updateFunction);
80-
});
78+
};
79+
80+
window.addEventListener("load", onLoad);

0 commit comments

Comments
 (0)