From 5389d4fc136202742aa6ca6477d7f4c756d58b27 Mon Sep 17 00:00:00 2001 From: jordy Date: Sun, 23 Apr 2023 14:16:28 +0200 Subject: [PATCH] always scrollcontainer by page width on move --- src/main/resources/templates/multi-tool.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/resources/templates/multi-tool.html b/src/main/resources/templates/multi-tool.html index cc6ae337..5d911403 100644 --- a/src/main/resources/templates/multi-tool.html +++ b/src/main/resources/templates/multi-tool.html @@ -162,6 +162,7 @@ const moveUpButtonCallback = e => { var imgContainer = e.target; + const startingPosition = imgContainer.getBoundingClientRect(); while (!imgContainer.classList.contains("page-container")) { imgContainer = imgContainer.parentNode; } @@ -169,9 +170,10 @@ if (sibling) { pagesContainer.removeChild(imgContainer); pagesContainer.insertBefore(imgContainer, sibling); - imgContainer.scrollIntoView({ - behavior: "instant", - block: "center", + + const { width } = imgContainer.getBoundingClientRect(); + pagesContainerWrapper.scroll({ + left: pagesContainerWrapper.scrollLeft - width, }) } }; @@ -188,9 +190,9 @@ } else { pagesContainer.appendChild(imgContainer) } - imgContainer.scrollIntoView({ - behavior: "instant", - block: "center", + const { width } = imgContainer.getBoundingClientRect(); + pagesContainerWrapper.scroll({ + left: pagesContainerWrapper.scrollLeft + width, }) } };