Perf: use scrollTop replace with srcollY

This commit is contained in:
Cell
2022-09-17 15:04:20 +08:00
parent d6d6638d92
commit f93fa4e870
3 changed files with 3 additions and 3 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1047,7 +1047,7 @@ class FixIt {
}
});
const contentHeight = document.body.scrollHeight - window.innerHeight;
const scrollPercent = contentHeight > 0 ? Math.min(100 * (window.scrollY < 0 ? 0 : window.scrollY) / contentHeight, 100) : 0;
const scrollPercent = Math.max(Math.min(100 * Math.max(this.newScrollTop, 0) / contentHeight, 100), 0);
if ($readingProgressBar) {
$readingProgressBar.style.setProperty('--progress', `${scrollPercent.toFixed(2)}%`);
}