motion icon indicating copy to clipboard operation
motion copied to clipboard

[BUG] Wrong drag values / motion when parent container has a scale transform

Open leoncvlt opened this issue 9 months ago • 1 comments

2. Describe the bug

The drag functionality seems to have some issues when the dragged motion element is a child of a parent with a transform: scale applied to it - the motions seems to be "offsetted" by the scaled amount. Other than over/under-dragging, the also results in the element having the wrong "internal" position and jumping around when animating after being given a different layout position.

3. IMPORTANT: Provide a CodeSandbox reproduction of the bug

https://codesandbox.io/p/sandbox/7yywy5

4. Steps to reproduce

Steps to reproduce the behavior:

  1. Drag the red box around. As the parent container scale is 0.5, The drag "delta" is half of what it should be, and the box will lag behind the cursor.

5. Expected behavior

The box should follow the cursor without lagging behind, and x/y values should make up for the scaling up in the hierarchy.

I can understand why this would happen - is there a way to offset or scale the motion drag functionality values to make up for this, as I would know the scaled amount of the parents container? The x and y style values seem to be independent of the dragging. Couldn't come up with much about this other than disabling drag altogether, and re-implementing it on my side.

Thanks in advance!

leoncvlt avatar Mar 28 '25 15:03 leoncvlt

Encountered this as well. Setting scale on the initial object ( initial={{ scale: 0.5 }} ) fixes this -- it just flickers with the wrong position every now and then.

Flesky avatar Apr 28 '25 22:04 Flesky