Skip to content

Commit

Permalink
fix: ensure delta correct for transforms and size changes
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Nov 12, 2024
1 parent d111206 commit d3a0646
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions packages/dom/src/core/plugins/feedback/Feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
generateUniqueId,
getDocument,
getFrameTransform,
type Transform,
DOMRectangle,
getFrameElement,
} from '@dnd-kit/dom/utilities';
Expand Down Expand Up @@ -155,20 +154,25 @@ export class Feedback extends Plugin<DragDropManager, FeedbackOptions> {
x: initialCoordinates.x - relativeLeft,
y: initialCoordinates.y - relativeTop,
};

const sizeDelta = {
width:
(initialSize.width / initialFrameTransform.scaleX -
width / frameTransform.scaleX) *
transformOrigin.x,
initialSize.width * initialFrameTransform.scaleX -
width * frameTransform.scaleX,
height:
(initialSize.height / initialFrameTransform.scaleY -
height / frameTransform.scaleY) *
transformOrigin.y,
initialSize.height * initialFrameTransform.scaleY -
height * frameTransform.scaleY,
};

const delta = {
x: coordinatesDelta.x / frameTransform.scaleX - sizeDelta.width,
y: coordinatesDelta.y / frameTransform.scaleY - sizeDelta.height,
x:
coordinatesDelta.x / frameTransform.scaleX +
sizeDelta.width * transformOrigin.x,
y:
coordinatesDelta.y / frameTransform.scaleY +
sizeDelta.height * transformOrigin.y,
};

const projected = {
left: left + delta.x,
top: top + delta.y,
Expand Down

0 comments on commit d3a0646

Please sign in to comment.