From 66980eef23ffbeda916395305c83e1b989d47ed8 Mon Sep 17 00:00:00 2001 From: glax Date: Thu, 25 May 2023 16:05:54 +0200 Subject: [PATCH] Position publication viewer always withing display --- Website/interaction.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Website/interaction.js b/Website/interaction.js index b04de0a..7671103 100644 --- a/Website/interaction.js +++ b/Website/interaction.js @@ -134,9 +134,21 @@ function ResetContent(){ tasksContent.appendChild(add); } function ShowPublicationViewerWindow(publicationId, event, add){ + + + //Show popup + publicationViewerPopup.style.display = "block"; + //Set position to mouse-position - publicationViewerWindow.style.top = `${event.clientY - 60}px`; - publicationViewerWindow.style.left = `${event.clientX}px`; + if(event.clientY < window.innerHeight - publicationViewerWindow.offsetHeight) + publicationViewerWindow.style.top = `${event.clientY}px`; + else + publicationViewerWindow.style.top = `${event.clientY - publicationViewerWindow.offsetHeight}px`; + + if(event.clientX < window.innerWidth - publicationViewerWindow.offsetWidth) + publicationViewerWindow.style.left = `${event.clientX}px`; + else + publicationViewerWindow.style.left = `${event.clientX - publicationViewerWindow.offsetWidth}px`; //Edit information inside the window var publication = publications.filter(pub => pub.internalId === publicationId)[0]; @@ -155,9 +167,6 @@ function ShowPublicationViewerWindow(publicationId, event, add){ publicationAdd.style.display = "none"; publicationDelete.style.display = "block"; } - - //Show popup - publicationViewerPopup.style.display = "block"; } function HidePublicationPopup(){