adding fullscreen mode

This commit is contained in:
Christian Aribaud 2023-04-16 17:43:37 +02:00
parent ac2a51f066
commit ebf21375ef
2 changed files with 38 additions and 2 deletions

View File

@ -18,6 +18,9 @@ CURRENT_Y = 0
IS_PAGE_MODE = false
MOUSEWHELL_MIN_DELAY = 50
MOUSEWHELL_WAIT = false
// ===========
// UTILITIES
// ===========
@ -267,6 +270,35 @@ function handleKeyPress(key, has_ctrl){
moveReader(false, has_ctrl)
}
else if (key == "f"){
if (document.fullscreenElement == null){
READER_FRAME.requestFullscreen();
} else {
document.exitFullscreen();
}
}
}
function handleMouseWhell(deltaY){
if (MOUSEWHELL_WAIT){
return
} else {
MOUSEWHELL_WAIT = true
setTimeout(() => {
MOUSEWHELL_WAIT = false
}, MOUSEWHELL_MIN_DELAY)
}
if (deltaY > 0) {
moveReader(true, false)
}
else {
moveReader(false, false)
}
}
// ======
@ -284,3 +316,7 @@ addEventListener("resize", (event) => {
addEventListener("keydown", (event) => {
handleKeyPress(event.key, event.ctrlKey)
});
addEventListener("wheel", (event) => {
handleMouseWhell(event.deltaY)
});

View File

@ -6,7 +6,7 @@ html, body {
}
body {
padding: 1em;
padding: 4em;
height: 100vh;
background-color: whitesmoke;
}