mirror of
https://github.com/Wonderfall/hugo-WonderMod.git
synced 2024-11-24 03:21:37 +01:00
add progressbar
This commit is contained in:
parent
0a140a1a12
commit
13876beb0a
@ -171,3 +171,12 @@ body:not(.dark) #sun {
|
||||
.logo-switches {
|
||||
flex-wrap: inherit;
|
||||
}
|
||||
|
||||
#progressBar {
|
||||
--scrollAmount: 0%;
|
||||
width: var(--scrollAmount);
|
||||
height: 3px;
|
||||
background-color: rgb(0, 128, 128);
|
||||
position: fixed;
|
||||
z-index: 9999;
|
||||
}
|
@ -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();
|
@ -11,6 +11,9 @@
|
||||
{{- end }}
|
||||
|
||||
<header class="header">
|
||||
{{- if .IsPage }}
|
||||
<div id="progressBar"></div>
|
||||
{{- end }}
|
||||
<nav class="nav">
|
||||
<div class="logo">
|
||||
{{- $label_text := (site.Params.label.text | default site.Title) }}
|
||||
|
Loading…
Reference in New Issue
Block a user