简体   繁体   中英

HTML Drag and Drop - determine position within object

I am trying to determine the position within a div where the drop occurs (relative to the center point). The goal would be to determine if the drop is above, below, right or left. So far, I can only find the coordinates of the event (SyntheticBaseEvent) clientX/Y, but not the coordinates of the target being dropped on. Is there a way to determine this?

You can by getting the coordinates of the div and working from there

element.getBoundingClientRect();

Hope it helped

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM