onDragEnd delta.y property inaccurate when inside position fixed container
See original GitHub issueI’ve encountered an issue where the delta.y
property on the onDragEnd
callback of DndContext
shows an incorrect result if the container element is inside an element that does not scroll with the page. The issue is much easier to show than explain, so I created a CodeSandbox for it: https://codesandbox.io/s/headless-glitter-54n1r?file=/src/App.js
In the real world, I’m trying to drag a little circle over an image and have the circle stay exactly where it is dropped. I was using the delta.x and delta.y properties to calculate the final CSS position based on the starting point and the width/height of the image. In my case, the image is inside a bootstrap modal, but for the codesandbox I just used a simple position:fixed div for demonstration purposes.
Is there a workaround for this? Or perhaps a better way to accomplish what I’m attempting to do? I found a random codepen that shows what I’m trying to accomplish: https://codepen.io/vinsongrant/pen/QGodXV
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top GitHub Comments
@nc my very “hacky” solution was to subtract the scrollTop from delta.y. Since my modal was scrolling, I also had to subtract the modal scrollTop.
@srmagura yeah I’m facing that issue too, even with the latest version.