From 64dbb0a1e70e3ba0560adca177f05a937be2f2d4 Mon Sep 17 00:00:00 2001 From: Christian Aribaud Date: Sun, 16 Apr 2023 21:35:32 +0200 Subject: [PATCH] Moving constants to own section --- comic_reader.js | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/comic_reader.js b/comic_reader.js index 8631bc8..9d6da41 100644 --- a/comic_reader.js +++ b/comic_reader.js @@ -1,29 +1,42 @@ +//============ +// CONTROLS +//============ + +MOVE_NEXT = "ArrowRight" +MOVE_BACK = "ArrowLeft" +TOGGLE_FULLSCREEN = "F" + + +//======================== +// NAVIGATION CONSTANTS +//======================== PAGE_TRANSITION_SPEED = "1.5s" +MOUSEWHELL_MIN_DELAY = 50 + + +//==================== +// STATES CONSTANTS +//==================== READER_FRAME = document.getElementById("reader-frame") - READER_PAGES = document.getElementById("reader-pages") - FOCUS_OVERLAY = document.getElementById("focus-overlay") CURRENT_ZOOM = 0 - CURRENT_PAGE = 1 - CURRENT_WIDTH = 0 CURRENT_HEIGHT = 0 CURRENT_X = 0 CURRENT_Y = 0 IS_PAGE_MODE = false - -MOUSEWHELL_MIN_DELAY = 50 MOUSEWHELL_WAIT = false -// =========== -// UTILITIES -// =========== + +// ============= +// UTILITIES +// ============= // Zooms utilites // -------------- @@ -260,17 +273,22 @@ function moveReader(to_next, move_page) { } + +// ============= +// CALLBACKS +// ============= + function handleKeyPress(key, has_ctrl){ - if (key == "ArrowRight") { + if (key == MOVE_NEXT) { moveReader(true, has_ctrl) } - else if (key == "ArrowLeft") { + else if (key == MOVE_BACK) { moveReader(false, has_ctrl) } - else if (key == "f"){ + else if (key.toUpperCase() == TOGGLE_FULLSCREEN){ if (document.fullscreenElement == null){ READER_FRAME.requestFullscreen(); } else {