daybrush / infinite-viewer

Infinite Viewer is Document Viewer Component with infinite scrolling.
https://daybrush.com/infinite-viewer/
MIT License
283 stars 30 forks source link

How to obtain the relative coordinates of a dragged element (relative to its parent element) #35

Closed hhbusui closed 1 year ago

hhbusui commented 1 year ago

problem

Hey, author

When dropping the drag item, obtain its relative coordinates。

operation

image

Code structure

image

Looking forward to your reply,thank you

daybrush commented 1 year ago

@hhbusui

Using getElementRect will give you the exact location.

https://github.com/daybrush/moveable/issues/797#issuecomment-1321015856

The hitTest method will give you an idea of how much the hit is, but it's approximate.

moveable.hitTest(element); // 0 ~ 100
hhbusui commented 1 year ago

Thank you for your reply, which perfectly solved my problem.