fix: firefox scroll
This commit is contained in:
parent
87d60ac76b
commit
b5a267d84b
23
src/scripts/firefox-scroll.js
Normal file
23
src/scripts/firefox-scroll.js
Normal file
@ -0,0 +1,23 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
window.scrollTo(0, 1);
|
||||
let scrollTop = 1;
|
||||
let fromTop = () => {
|
||||
return window.pageYOffset || document.compatMode === "CSS1Compat" && document.documentElement.scrollTop || document.body.scrollTop || 0;
|
||||
};
|
||||
|
||||
let isbody = setInterval(() => {
|
||||
if (document.body) {
|
||||
clearInterval(isbody);
|
||||
scrollTop = fromTop();
|
||||
window.scrollTo(0, scrollTop === 1 ? 0 : 1);
|
||||
}
|
||||
}, 15);
|
||||
|
||||
window.addEventListener("load", () => {
|
||||
setTimeout(() => {
|
||||
if (fromTop() < 20) {
|
||||
window.scrollTo(0, scrollTop === 1 ? 0 : 1);
|
||||
}
|
||||
}, 0);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user