diff --git a/comic_reader.css b/comic_reader.css index e391acf..39df8cb 100644 --- a/comic_reader.css +++ b/comic_reader.css @@ -104,7 +104,7 @@ } #help-menu > #help-controls { - padding: 0 1em 1em 0; + padding: 0 1em 1em 1em; background-color: rgba(0,0,0,0.5); z-index: 1; opacity: 0; @@ -123,7 +123,7 @@ #help-menu > #help-controls > div { margin-top: 1em; - text-align: end; + text-align: center; } .key { diff --git a/comic_reader.js b/comic_reader.js index 4dcea05..938ca2a 100644 --- a/comic_reader.js +++ b/comic_reader.js @@ -6,6 +6,7 @@ MOVE_NEXT = "ArrowRight" MOVE_BACK = "ArrowLeft" TOGGLE_FULLSCREEN = "F" TOGGLE_PROGRESSBAR = "P" +TOGGLE_VIEW_MODE = "V" //======================== @@ -245,66 +246,41 @@ function updateFocusByHeight(height){ FOCUS_OVERLAY.style.gridTemplateColumns = "0px auto 0px"; } -function moveReader(to_next, move_page) { - - if (move_page){ +function toggleViewMode() { + if (IS_PAGE_MODE){ + if (CURRENT_ZOOM != null){ + moveReaderDisplayToZoom(CURRENT_ZOOM) + } else { + moveReaderDisplayToZoom(getFirstZoomOfPage(CURRENT_PAGE)) + } + IS_PAGE_MODE = false + } else { + moveReaderDisplayToPage(CURRENT_PAGE) + IS_PAGE_MODE = true + } +} + +function moveReader(to_next) { - if (IS_PAGE_MODE){ - if (to_next && CURRENT_PAGE < getPagesCount()) { - moveReaderDisplayToPage(CURRENT_PAGE + 1) - IS_PAGE_MODE = true - } - - else if (!to_next && CURRENT_PAGE > 1) { - moveReaderDisplayToPage(CURRENT_PAGE - 1) - IS_PAGE_MODE = true - } + if (IS_PAGE_MODE){ + if (to_next && CURRENT_PAGE < getPagesCount()) { + moveReaderDisplayToPage(CURRENT_PAGE + 1) + CURRENT_ZOOM = null } - else { - - if (to_next && CURRENT_PAGE < getPagesCount()) { - moveReaderDisplayToPage(CURRENT_PAGE + 1) - IS_PAGE_MODE = true - } - - else { - moveReaderDisplayToPage(CURRENT_PAGE) - IS_PAGE_MODE = true - } - + else if (!to_next && CURRENT_PAGE > 1) { + moveReaderDisplayToPage(CURRENT_PAGE - 1) + CURRENT_ZOOM = null } } else { + + if (to_next && CURRENT_ZOOM < zooms.length - 1) { + moveReaderDisplayToZoom(CURRENT_ZOOM + 1) + } - if (IS_PAGE_MODE){ - - if (to_next) { - moveReaderDisplayToZoom(getFirstZoomOfPage(CURRENT_PAGE)) - IS_PAGE_MODE = false - } - else { - if (CURRENT_PAGE == 1) { - moveReaderDisplayToZoom(0) - IS_PAGE_MODE = false - } else { - moveReaderDisplayToZoom(getLastZoomOfPage(CURRENT_PAGE - 1)) - IS_PAGE_MODE = false - } - } - - } else { - - if (to_next && CURRENT_ZOOM < zooms.length - 1) { - moveReaderDisplayToZoom(CURRENT_ZOOM + 1) - IS_PAGE_MODE = false - } - - else if (!to_next && CURRENT_ZOOM > 0) { - moveReaderDisplayToZoom(CURRENT_ZOOM - 1) - IS_PAGE_MODE = false - } - + else if (!to_next && CURRENT_ZOOM > 0) { + moveReaderDisplayToZoom(CURRENT_ZOOM - 1) } } @@ -317,14 +293,14 @@ function moveReader(to_next, move_page) { // CALLBACKS // ============= -function handleKeyPress(key, has_shift){ +function handleKeyPress(key){ if (key == MOVE_NEXT) { - moveReader(true, has_shift) + moveReader(true) } else if (key == MOVE_BACK) { - moveReader(false, has_shift) + moveReader(false) } else if (key.toUpperCase() == TOGGLE_FULLSCREEN){ @@ -344,6 +320,10 @@ function handleKeyPress(key, has_shift){ } refreshReaderDisplay(); } + + else if (key.toUpperCase() == TOGGLE_VIEW_MODE) { + toggleViewMode() + } } diff --git a/comic_reader_test_high_res.html b/comic_reader_test_high_res.html index 19d4de3..212f1bb 100644 --- a/comic_reader_test_high_res.html +++ b/comic_reader_test_high_res.html @@ -43,11 +43,12 @@