Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update htmlv2.pug - Fixed Top and Bottom Controllers not Activating, Added Per-Story ScrollSave Support, Fixed irresponsive layouts in Mobile view. #9

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions templates/htmlv2.pug
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ style.
display: flex;
flex-direction: column;
line-height: 1.5;
word-wrap: break-word;
overflow-wrap: break-word;
}

.part img {
Expand Down Expand Up @@ -160,6 +162,7 @@ html(lang=langName)
meta(charset="UTF-8")
title= book.title
meta(name="viewport" content="width=device-width, initial-scale=1.0")
meta(name="scroll-key" content= book.id)

body

Expand Down Expand Up @@ -203,7 +206,13 @@ html(lang=langName)

script.
const fontList = ["Arial, sans-serif", "Verdana, sans-serif", "Cambria, serif", "cursive", "monospace"];
let scrollsave = localStorage.getItem("scrollsave");
const scrollKey = document.querySelector('meta[name="scroll-key"]')?.content;
let scrollsave;
if (scrollKey) {
scrollsave = localStorage.getItem(`scrollsave_${scrollKey}`);
} else {
console.warn("No scroll key defined in the HTML.");
}
let fontsize = localStorage.getItem("fontsize");
let colormode = localStorage.getItem("colormode");
let font = localStorage.getItem("font");
Expand All @@ -229,7 +238,7 @@ script.

window.addEventListener("click", (event) => {

if(!event.path.find((el) => el.id === "top-control" || el.id === "bottom-control")){
if(!event.composedPath().some((el) => el.id === "top-control" || el.id === "bottom-control")){
document.querySelector("#top-control").classList.toggle("active");
document.querySelector("#bottom-control").classList.toggle("active");
}
Expand All @@ -249,7 +258,7 @@ script.
window.clearTimeout(isScrolling);

isScrolling = setTimeout(() => {
localStorage.setItem("scrollsave", currentScroll.toString());
localStorage.setItem(`scrollsave_${scrollKey}`, currentScroll.toString());
}, 80);

});
Expand Down