♻️ Refactor: refactor reading progress with css animation

This commit is contained in:
Cell
2024-11-11 12:25:23 +08:00
parent ad01016092
commit c91c0c8d52
3 changed files with 37 additions and 17 deletions
-4
View File
@@ -1171,7 +1171,6 @@ class FixIt {
const ACCURACY = 20;
const $fixedButtons = document.querySelector('.fixed-buttons');
const $backToTop = document.querySelector('.back-to-top');
const $readingProgressBar = document.querySelector('.reading-progress-bar');
if (document.body.dataset.headerDesktop === 'auto') {
$headers.push(document.getElementById('header-desktop'));
}
@@ -1204,9 +1203,6 @@ class FixIt {
});
const contentHeight = document.body.scrollHeight - window.innerHeight;
const scrollPercent = Math.max(Math.min(100 * Math.max(this.newScrollTop, 0) / contentHeight, 100), 0);
if ($readingProgressBar) {
$readingProgressBar.style.setProperty('--progress', `${scrollPercent.toFixed(2)}%`);
}
// whether to show fixed buttons
if ($fixedButtons) {
if (scrollPercent > 1) {