From 87925ac618feb08c22fc65f33595e7d1bdeb0685 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Sun, 15 Sep 2024 13:08:12 +0100 Subject: [PATCH] --- src/main/resources/static/css/rotate-pdf.css | 13 +++++++++++++ .../static/js/multitool/PdfActionsManager.js | 17 +++++++++++++++++ .../static/js/multitool/PdfContainer.js | 6 ++++++ 3 files changed, 36 insertions(+) diff --git a/src/main/resources/static/css/rotate-pdf.css b/src/main/resources/static/css/rotate-pdf.css index 57a30024d..19024e207 100644 --- a/src/main/resources/static/css/rotate-pdf.css +++ b/src/main/resources/static/css/rotate-pdf.css @@ -27,3 +27,16 @@ display: flex; justify-content: space-around; } + +#pdf-preview-large { + margin: 0 auto; + display: block; + max-width: calc(100% - 30px); + max-height: calc(100% - 30px); + box-shadow: 0 0 4px rgba(100, 100, 100, 0.25); + transition: rotate 0.3s; + position: absolute; + top: 50%; + left: 50%; + translate: -50% -50%; +} diff --git a/src/main/resources/static/js/multitool/PdfActionsManager.js b/src/main/resources/static/js/multitool/PdfActionsManager.js index 3701266e2..46722ab1a 100644 --- a/src/main/resources/static/js/multitool/PdfActionsManager.js +++ b/src/main/resources/static/js/multitool/PdfActionsManager.js @@ -192,6 +192,23 @@ class PdfActionsManager { return div; } + + rotateElement(element, deg) { + var lastTransform = element.style.rotate; + if (!lastTransform) { + lastTransform = "0"; + } + const lastAngle = parseInt(lastTransform.replace(/[^\d-]/g, "")); + const newAngle = lastAngle + deg; + + element.style.rotate = newAngle + "deg"; + + // Update the larger preview rotation + const previewElement = document.getElementById("pdf-preview"); + if (previewElement) { + previewElement.style.rotate = newAngle + "deg"; + } + } } export default PdfActionsManager; diff --git a/src/main/resources/static/js/multitool/PdfContainer.js b/src/main/resources/static/js/multitool/PdfContainer.js index 55635c69e..2fd7cf2bb 100644 --- a/src/main/resources/static/js/multitool/PdfContainer.js +++ b/src/main/resources/static/js/multitool/PdfContainer.js @@ -117,6 +117,12 @@ class PdfContainer { const newAngle = lastAngle + deg; element.style.rotate = newAngle + "deg"; + + // Update the larger preview rotation + const previewElement = document.getElementById("pdf-preview"); + if (previewElement) { + previewElement.style.rotate = newAngle + "deg"; + } } async addPdfFile(file, nextSiblingElement) {