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`;