Moving constants to own section

This commit is contained in:
Christian Aribaud 2023-04-16 21:35:32 +02:00
parent ebf21375ef
commit 64dbb0a1e7
1 changed files with 30 additions and 12 deletions

View File

@ -1,29 +1,42 @@
//============
// CONTROLS
//============
MOVE_NEXT = "ArrowRight"
MOVE_BACK = "ArrowLeft"
TOGGLE_FULLSCREEN = "F"
//========================
// NAVIGATION CONSTANTS
//========================
PAGE_TRANSITION_SPEED = "1.5s" PAGE_TRANSITION_SPEED = "1.5s"
MOUSEWHELL_MIN_DELAY = 50
//====================
// STATES CONSTANTS
//====================
READER_FRAME = document.getElementById("reader-frame") READER_FRAME = document.getElementById("reader-frame")
READER_PAGES = document.getElementById("reader-pages") READER_PAGES = document.getElementById("reader-pages")
FOCUS_OVERLAY = document.getElementById("focus-overlay") FOCUS_OVERLAY = document.getElementById("focus-overlay")
CURRENT_ZOOM = 0 CURRENT_ZOOM = 0
CURRENT_PAGE = 1 CURRENT_PAGE = 1
CURRENT_WIDTH = 0 CURRENT_WIDTH = 0
CURRENT_HEIGHT = 0 CURRENT_HEIGHT = 0
CURRENT_X = 0 CURRENT_X = 0
CURRENT_Y = 0 CURRENT_Y = 0
IS_PAGE_MODE = false IS_PAGE_MODE = false
MOUSEWHELL_MIN_DELAY = 50
MOUSEWHELL_WAIT = false MOUSEWHELL_WAIT = false
// ===========
// UTILITIES // =============
// =========== // UTILITIES
// =============
// Zooms utilites // Zooms utilites
// -------------- // --------------
@ -260,17 +273,22 @@ function moveReader(to_next, move_page) {
} }
// =============
// CALLBACKS
// =============
function handleKeyPress(key, has_ctrl){ function handleKeyPress(key, has_ctrl){
if (key == "ArrowRight") { if (key == MOVE_NEXT) {
moveReader(true, has_ctrl) moveReader(true, has_ctrl)
} }
else if (key == "ArrowLeft") { else if (key == MOVE_BACK) {
moveReader(false, has_ctrl) moveReader(false, has_ctrl)
} }
else if (key == "f"){ else if (key.toUpperCase() == TOGGLE_FULLSCREEN){
if (document.fullscreenElement == null){ if (document.fullscreenElement == null){
READER_FRAME.requestFullscreen(); READER_FRAME.requestFullscreen();
} else { } else {