From 7f6a50c3c22f44238db28a109a614dbfe6bd42b1 Mon Sep 17 00:00:00 2001 From: al Date: Wed, 21 Aug 2024 16:33:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/ImagesMask/index.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/ImagesMask/index.jsx b/components/ImagesMask/index.jsx index ea5532d..a2da599 100644 --- a/components/ImagesMask/index.jsx +++ b/components/ImagesMask/index.jsx @@ -158,15 +158,18 @@ const ImagesMaskContaint = forwardRef( // ref.current.children[0].style.transform = // "matrix(" + size + ", 0, 0, " + size + ", 0, 0)"; // } + if (zoomed) { let currentX = touches[0].clientX - initialMoveX; let currentY = touches[0].clientY - initialMoveY; // console.log(currentX + xOffsetMove); - if (Math.abs(currentX + xOffsetMove) > window.innerWidth) return; + let currentDom = + ref.current.children[currentIndex].getBoundingClientRect(); + if (Math.abs(currentX + xOffsetMove) > currentDom.width / 3) return; ref.current.children[currentIndex].style.left = `${ currentX + xOffsetMove }px`; - if (Math.abs(currentY + yOffsetMove - 54) > window.innerHeight) return; + if (Math.abs(currentY + yOffsetMove) > currentDom.height / 3) return; ref.current.children[currentIndex].style.top = `${ currentY + yOffsetMove - 54 }px`;