fix: firefox scroll

This commit is contained in:
Jean-Baptiste Pasquier 2020-10-14 23:40:08 +02:00 committed by gaelle morin
parent 5428e5aa54
commit 5ec1bc5c13
No known key found for this signature in database
GPG Key ID: 028426702B95CF9C
1 changed files with 23 additions and 0 deletions

View 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);
});
});