From bbe39d489204ff56d1cd11f9489815d0e4a8aaf7 Mon Sep 17 00:00:00 2001 From: Nassim's Software Date: Thu, 16 Feb 2023 16:26:03 -0500 Subject: [PATCH] fixed ctrl+wheel zooming in readermode --- reader/reader.js | 26 +++++++++++++++++++++++++- reader/readerUI.css | 16 ++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/reader/reader.js b/reader/reader.js index 8bc41da25..020553aad 100644 --- a/reader/reader.js +++ b/reader/reader.js @@ -265,7 +265,31 @@ function startReaderView (article, date) { window.addEventListener('resize', setReaderFrameSize) } - document.body.appendChild(rframe) + + const overlayForZooming = document.createElement('div') + overlayForZooming.id = 'overlay' + + rframe.addEventListener('load', function () { + rframe.contentWindow.document.addEventListener('keydown', function (e) { + if (e.getModifierState('Control')) { + overlayForZooming.style.pointerEvents = 'auto' + } + }) + + rframe.contentWindow.document.addEventListener('keyup', function (e) { + if (e.key === 'Control') { + overlayForZooming.style.pointerEvents = 'none' + } + }) + }) + + const container = document.createElement('div') + container.id = 'container' + + container.appendChild(overlayForZooming) + container.appendChild(rframe) + + document.body.appendChild(container) } function processArticle (data) { diff --git a/reader/readerUI.css b/reader/readerUI.css index e8c237663..aaf1b8160 100644 --- a/reader/readerUI.css +++ b/reader/readerUI.css @@ -219,3 +219,19 @@ body:not([theme="light"]) #site-nav-links a { body:not([theme="light"]) #site-nav-links a.selected { opacity: 0.75; } + +#container { + position: relative; + width: 100%; + height: 100%; +} + +#overlay { + position: absolute; + top: 0; + left: 0; + z-index: 1; + width: 100%; + height: 100%; + pointer-events: none; +} \ No newline at end of file