diff --git a/comic_reader.js b/comic_reader.js index 5d34308..8631bc8 100644 --- a/comic_reader.js +++ b/comic_reader.js @@ -18,6 +18,9 @@ CURRENT_Y = 0 IS_PAGE_MODE = false +MOUSEWHELL_MIN_DELAY = 50 +MOUSEWHELL_WAIT = false + // =========== // UTILITIES // =========== @@ -266,9 +269,38 @@ function handleKeyPress(key, has_ctrl){ else if (key == "ArrowLeft") { 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 // ====== @@ -283,4 +315,8 @@ addEventListener("resize", (event) => { addEventListener("keydown", (event) => { handleKeyPress(event.key, event.ctrlKey) -}); \ No newline at end of file +}); + +addEventListener("wheel", (event) => { + handleMouseWhell(event.deltaY) +}); diff --git a/comic_reader_test.css b/comic_reader_test.css index fa501ad..05a357a 100644 --- a/comic_reader_test.css +++ b/comic_reader_test.css @@ -6,7 +6,7 @@ html, body { } body { - padding: 1em; + padding: 4em; height: 100vh; background-color: whitesmoke; }