From 07e0369c6ce5e891e2a97686d51e667a9333b4ef Mon Sep 17 00:00:00 2001 From: jrajan <60109092+Jyotsnarajan@users.noreply.github.com> Date: Fri, 22 Nov 2024 14:46:19 +0530 Subject: [PATCH] [clientapp] auto-adjust zoom sizefor blobs (#210) * [clientapp] auto-adjust zoom sizefor blobs * [clientapp] remove unwanted line of code --- ipol_demo/clientApp/js/demo.editor.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ipol_demo/clientApp/js/demo.editor.js b/ipol_demo/clientApp/js/demo.editor.js index f37269ef0..1fe9e5a00 100644 --- a/ipol_demo/clientApp/js/demo.editor.js +++ b/ipol_demo/clientApp/js/demo.editor.js @@ -161,7 +161,16 @@ function displayCrop($img){ } function setNaturalZoom() { - $("#editor-blob-left").cropper('zoomTo', 1); + var imageData = $("#editor-blob-left").cropper("getImageData"); + var containerData = $("#editor-blob-left").cropper("getContainerData"); + + const scale = Math.min( + containerData.width / imageData.naturalWidth, + containerData.height / imageData.naturalHeight + ); + + $("#editor-blob-left").cropper('zoomTo', scale); + } function getData() {