diff --git a/eslint/eslintrc.json b/eslint/eslintrc.json index 5fd6db2..92436b8 100644 --- a/eslint/eslintrc.json +++ b/eslint/eslintrc.json @@ -31,6 +31,8 @@ "function-paren-newline": ["warn", "consistent"], "no-magic-numbers": ["error", {"ignore": [0,1,2,100]}], "quote-props": ["warn", "as-needed"], - "no-unused-vars": ["error", {"argsIgnorePattern": "^_"}] + "no-unused-vars": ["error", {"argsIgnorePattern": "^_"}], + "max-len" : ["warn", {"code": 88}], + "capitalized-comments": "off" } } diff --git a/melpomene.js b/melpomene.js index 87a73ab..be4f664 100644 --- a/melpomene.js +++ b/melpomene.js @@ -327,10 +327,10 @@ function moveReaderDisplayToArea(pageNumber, oWidth, oHeight, oPosx, oPosy) // Align the top-left corner of the frame with the page - READER_PAGES.style.transform = "translate(-" + previousPagesWidth(pageNumber) + "px, -" + pageVerticalOffset(pageNumber) + "px )"; + READER_PAGES.style.transform = `translate(-${previousPagesWidth(pageNumber)}px, -${pageVerticalOffset(pageNumber)}px)`; // Then move so the top-left point of the zoom match the frame top-left - READER_PAGES.style.transform = "translate(" + (- posx) + "px, " + (-posy) + "px )" + READER_PAGES.style.transform; + READER_PAGES.style.transform = `translate(${-posx}px, ${-posy}px) ${READER_PAGES.style.transform}`; // Then, scale so the zoom would fit the frame, and center the zoom if (width === 0) @@ -350,12 +350,12 @@ function moveReaderDisplayToArea(pageNumber, oWidth, oHeight, oPosx, oPosy) // Frame wider than zoom => scale so heights are the same, offset on x const zoomToFrameScaleFactor = READER_CONTENT_FRAME.clientHeight / height; - READER_PAGES.style.transform = "scale(" + zoomToFrameScaleFactor + ")" + READER_PAGES.style.transform; + READER_PAGES.style.transform = `scale(${zoomToFrameScaleFactor}) ${READER_PAGES.style.transform}`; const scaledWidth = width * zoomToFrameScaleFactor; const offset = (READER_CONTENT_FRAME.clientWidth - scaledWidth) / 2; - READER_PAGES.style.transform = "translateX(" + offset + "px)" + READER_PAGES.style.transform; + READER_PAGES.style.transform = `translateX(${offset}px) ${READER_PAGES.style.transform}`; updateFocusByWidth(scaledWidth); } @@ -365,12 +365,12 @@ function moveReaderDisplayToArea(pageNumber, oWidth, oHeight, oPosx, oPosy) // Frame narower than zoom => scale so left/right match, offset on y const zoomToFrameScaleFactor = READER_CONTENT_FRAME.clientWidth / width; - READER_PAGES.style.transform = "scale(" + zoomToFrameScaleFactor + ")" + READER_PAGES.style.transform; + READER_PAGES.style.transform = `scale(${zoomToFrameScaleFactor}) ${READER_PAGES.style.transform}`; const scaledHeight = height * zoomToFrameScaleFactor; const offset = (READER_CONTENT_FRAME.clientHeight - scaledHeight) / 2; - READER_PAGES.style.transform = "translateY(" + offset + "px)" + READER_PAGES.style.transform; + READER_PAGES.style.transform = `translateY(${offset}px) ${READER_PAGES.style.transform}"`; updateFocusByHeight(scaledHeight); } @@ -402,28 +402,28 @@ function moveReaderDisplayToZoom(index) function updateFocusByWidth(width) { - FOCUS_OVERLAY_WIDTH.style.width = (width / READER_CONTENT_FRAME.clientWidth * 100) + "%"; + FOCUS_OVERLAY_WIDTH.style.width = `${width / READER_CONTENT_FRAME.clientWidth * 100}%`; FOCUS_OVERLAY_HEIGHT.style.height = "100%"; } function updateFocusByHeight(height) { FOCUS_OVERLAY_WIDTH.style.width = "100%"; - FOCUS_OVERLAY_HEIGHT.style.height = (height / READER_CONTENT_FRAME.clientHeight * 100) + "%"; + FOCUS_OVERLAY_HEIGHT.style.height = `${height / READER_CONTENT_FRAME.clientHeight * 100}%`; } function toggleViewMode() { if (IS_PAGE_MODE) { - if (CURRENT_ZOOM !== null) + if (CURRENT_ZOOM === null) { - moveReaderDisplayToZoom(CURRENT_ZOOM); + moveReaderDisplayToZoom(getFirstZoomOfPage(CURRENT_PAGE)); } else { - moveReaderDisplayToZoom(getFirstZoomOfPage(CURRENT_PAGE)); + moveReaderDisplayToZoom(CURRENT_ZOOM); } IS_PAGE_MODE = false; @@ -453,8 +453,11 @@ function moveReader(toNext) moveReaderDisplayToPage(CURRENT_PAGE - 1); CURRENT_ZOOM = null; } + + updateProgressBar(); } + // Zoom mode else { if (toNext && CURRENT_ZOOM < PAGES_ZOOMS.length - 1) @@ -466,9 +469,9 @@ function moveReader(toNext) { moveReaderDisplayToZoom(CURRENT_ZOOM - 1); } - } - updateProgressBar(); + updateProgressBar(); + } } @@ -529,7 +532,7 @@ function handleMouseWhell(event) // Do disable page scrolling when we do prev/next, though - if (! READER_FRAME.contains(event.target)) + if (!READER_FRAME.contains(event.target)) { return; } @@ -542,14 +545,11 @@ function handleMouseWhell(event) return; } - else - { - MOUSEWHELL_WAIT = true; - setTimeout( - () => { MOUSEWHELL_WAIT = false; }, - MOUSEWHELL_MIN_DELAY - ); - } + MOUSEWHELL_WAIT = true; + setTimeout( + () => { MOUSEWHELL_WAIT = false; }, + MOUSEWHELL_MIN_DELAY + ); if (event.deltaY > 0) {