add progressbar

This commit is contained in:
Wonderfall
2022-07-29 00:07:11 +02:00
parent 0a140a1a12
commit 13876beb0a
3 changed files with 25 additions and 3 deletions

View File

@ -107,13 +107,23 @@ function showCodeCopyButtons() {
function openToc() {
var toc = document.getElementById("toc");
if (toc && window.innerWidth > 1500 && window.innerHeight > 800) {
if (window.innerWidth > 1500 && window.innerHeight > 800) {
toc.open = true;
}
}
function progressBar() {
var bar = document.getElementById("progressBar");
document.addEventListener('scroll', () => {
var scrollPercent = document.documentElement.scrollTop / (document.documentElement.scrollHeight - window.innerHeight) * 100 + '%';
bar.style.setProperty("--scrollAmount", scrollPercent);
})
}
initializeMenu();
openToc();
if (params.scrollToTop) scrollToTop();
if (params.themeToggle) themeToggle();
if (params.showCodeCopyButtons) showCodeCopyButtons();
if (params.showCodeCopyButtons) showCodeCopyButtons();
if (document.getElementById("toc")) openToc();
if (document.getElementById("progressBar")) progressBar();