From 3dcde3f6053b21fabb6caabe9bc35b8da0d7152c Mon Sep 17 00:00:00 2001 From: Bin Chao Date: Wed, 25 Dec 2024 15:28:53 +0800 Subject: [PATCH] fix bug: bounds are calculated incorrectly when scale is setting --- src/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index e0d95477..96d33f48 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -341,15 +341,15 @@ export class Rnd extends React.PureComponent { const parentLeft = parentRect.left; const parentTop = parentRect.top; const left = (boundaryLeft - parentLeft) / scale; - const top = boundaryTop - parentTop; + const top = boundaryTop - parentTop / scale; if (!this.resizable) return; this.updateOffsetFromParent(); const offset = this.offsetFromParent; this.setState({ bounds: { - top: top - offset.top, + top: top - offset.top / scale, right: left + (boundary.offsetWidth - this.resizable.size.width) - offset.left / scale, - bottom: top + (boundary.offsetHeight - this.resizable.size.height) - offset.top, + bottom: top + (boundary.offsetHeight - this.resizable.size.height) - offset.top / scale, left: left - offset.left / scale, }, });