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 IS_PAGE_MODE = false
MOUSEWHELL_MIN_DELAY = 50
MOUSEWHELL_WAIT = false
// =========== // ===========
// UTILITIES // UTILITIES
// =========== // ===========
@ -266,9 +269,38 @@ function handleKeyPress(key, has_ctrl){
else if (key == "ArrowLeft") { else if (key == "ArrowLeft") {
moveReader(false, 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)
}
}
// ====== // ======
// INIT // INIT
// ====== // ======
@ -283,4 +315,8 @@ addEventListener("resize", (event) => {
addEventListener("keydown", (event) => { addEventListener("keydown", (event) => {
handleKeyPress(event.key, event.ctrlKey) handleKeyPress(event.key, event.ctrlKey)
}); });
addEventListener("wheel", (event) => {
handleMouseWhell(event.deltaY)
});

View File

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