New reversed reading progress bar option (#221)

This commit is contained in:
2021-03-30 12:53:02 +08:00 committed by GitHub
parent 9ef3a63552
commit d46df43afe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View File

@ -377,8 +377,11 @@ back2top:
# Reading progress bar # Reading progress bar
reading_progress: reading_progress:
enable: false enable: false
# Available values: left | right
startAt: left
# Available values: top | bottom # Available values: top | bottom
position: top position: top
reversed: false
color: "#37c6c0" color: "#37c6c0"
height: 3px height: 3px

View File

@ -1,11 +1,22 @@
.reading-progress-bar { .reading-progress-bar {
--progress: 0;
background: unquote(hexo-config('reading_progress.color')); background: unquote(hexo-config('reading_progress.color'));
height: unquote(hexo-config('reading_progress.height')); height: unquote(hexo-config('reading_progress.height'));
left: 0;
position: fixed; position: fixed;
width: 0;
z-index: $zindex-5; z-index: $zindex-5;
if (hexo-config('reading_progress.reversed')) {
width: calc(100% - var(--progress));
} else {
width: var(--progress);
}
if (hexo-config('reading_progress.startAt') == 'right') {
right: 0;
} else {
left: 0;
}
if (hexo-config('reading_progress.position') == 'bottom') { if (hexo-config('reading_progress.position') == 'bottom') {
bottom: 0; bottom: 0;
} else { } else {

View File

@ -161,7 +161,7 @@ NexT.utils = {
backToTop.querySelector('span').innerText = Math.round(scrollPercent) + '%'; backToTop.querySelector('span').innerText = Math.round(scrollPercent) + '%';
} }
if (readingProgressBar) { if (readingProgressBar) {
readingProgressBar.style.width = scrollPercent.toFixed(2) + '%'; readingProgressBar.style.setProperty('--progress', scrollPercent.toFixed(2) + '%');
} }
} }
if (!Array.isArray(NexT.utils.sections)) return; if (!Array.isArray(NexT.utils.sections)) return;