address PR feedback

This commit is contained in:
jordy 2023-04-23 09:58:32 +02:00
parent 8f51f025d0
commit 3cb36d36bf

View file

@ -67,7 +67,7 @@
const pagesContainer = document.getElementById("pages-container"); const pagesContainer = document.getElementById("pages-container");
const pagesContainerWrapper = document.getElementById("pages-container-wrapper") const pagesContainerWrapper = document.getElementById("pages-container-wrapper")
const pageDirection = getComputedStyle(document.body).direction; const pageDirection = document.documentElement.getAttribute("lang-direction");
var scrollDelta = 0; // variable to store the accumulated scroll delta var scrollDelta = 0; // variable to store the accumulated scroll delta
var isScrolling = false; // variable to track if scroll is already in progress var isScrolling = false; // variable to track if scroll is already in progress
@ -106,7 +106,7 @@
* *
*/ */
const imageHighlighter = document.getElementById('image-highlighter'); const imageHighlighter = document.getElementById('image-highlighter');
imageHighlighter.onclick = (e) => { imageHighlighter.onclick = () => {
imageHighlighter.childNodes.forEach((child) => { imageHighlighter.childNodes.forEach((child) => {
child.classList.add('remove'); child.classList.add('remove');
setTimeout(() => { setTimeout(() => {
@ -115,6 +115,18 @@
}) })
} }
const imageHighlightCallback = (highlightEvent) => {
var bigImg = document.createElement('img');
bigImg.onclick = (imageClickEvent) => {
// This prevents the highlighter's onClick from closing the image when clicking on the image
// instead of next to it.
imageClickEvent.preventDefault();
imageClickEvent.stopPropagation();
};
bigImg.src = highlightEvent.target.src;
imageHighlighter.appendChild(bigImg);
}
/** /**
* *
* Methods for managing PDFs * Methods for managing PDFs
@ -227,15 +239,7 @@
/** /**
* Making pages larger when clicking on them * Making pages larger when clicking on them
*/ */
img.addEventListener('mousedown', (x) => { img.addEventListener('click',imageHighlightCallback)
var bigImg = document.createElement('img');
bigImg.onclick = (e) => {
e.preventDefault();
e.stopPropagation();
};
bigImg.src = imageSrc;
imageHighlighter.appendChild(bigImg);
})
/** /**
* Rendering the various buttons to manipulate and move pdf pages * Rendering the various buttons to manipulate and move pdf pages