mirror of
https://github.com/Wonderfall/hugo-WonderMod.git
synced 2024-11-21 18:11:37 +01:00
improve js
This commit is contained in:
parent
b43431bd51
commit
67efb771bf
@ -1,7 +1,7 @@
|
|||||||
import * as params from '@params';
|
import * as params from '@params';
|
||||||
|
|
||||||
function scrollToTop() {
|
function scrollToTop() {
|
||||||
var topButton = document.getElementById("top-link");
|
const topButton = document.getElementById("top-link");
|
||||||
|
|
||||||
document.addEventListener('scroll', () => {
|
document.addEventListener('scroll', () => {
|
||||||
if (document.body.scrollTop > 600 || document.documentElement.scrollTop > 600) {
|
if (document.body.scrollTop > 600 || document.documentElement.scrollTop > 600) {
|
||||||
@ -15,7 +15,7 @@ function scrollToTop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function themeToggle() {
|
function themeToggle() {
|
||||||
var themeButton = document.getElementById("theme-toggle");
|
const themeButton = document.getElementById("theme-toggle");
|
||||||
|
|
||||||
themeButton.addEventListener("click", () => {
|
themeButton.addEventListener("click", () => {
|
||||||
if (document.body.className.includes("dark")) {
|
if (document.body.className.includes("dark")) {
|
||||||
@ -77,7 +77,7 @@ function showCodeCopyButtons() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function openToc() {
|
function openToc() {
|
||||||
var toc = document.getElementById("toc");
|
const toc = document.getElementById("toc");
|
||||||
|
|
||||||
if (!toc) return;
|
if (!toc) return;
|
||||||
|
|
||||||
@ -87,12 +87,12 @@ function openToc() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function progressBar() {
|
function progressBar() {
|
||||||
var bar = document.getElementById("progressBar");
|
const bar = document.getElementById("progressBar");
|
||||||
|
|
||||||
if (!bar) return;
|
if (!bar) return;
|
||||||
|
|
||||||
document.addEventListener('scroll', () => {
|
document.addEventListener('scroll', () => {
|
||||||
var scrollPercent = document.documentElement.scrollTop / (document.documentElement.scrollHeight - window.innerHeight) * 100;
|
let scrollPercent = document.documentElement.scrollTop / (document.documentElement.scrollHeight - window.innerHeight) * 100;
|
||||||
if (scrollPercent >= 99) { scrollPercent = 0 };
|
if (scrollPercent >= 99) { scrollPercent = 0 };
|
||||||
bar.style.setProperty("--scrollAmount", scrollPercent + '%');
|
bar.style.setProperty("--scrollAmount", scrollPercent + '%');
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user