I'm creating a drag and drop system that includes sortables, and I'm trying to replicate jQuery's insertBefore/insertAfter
behavior when hovering over a list of elements. As such, I have an element under my cursor and I want to put a placeholder where it would show up in the list.
I've tried:
document.elementFromPoint
- this only gives me the topmost elementdocument.querySelectorAll(':hover')
- this gives me the containing list and the dragged element, but not the intermediate element that I would insert a placeholder before/after- checking
event.toElement, .srcElement
, etc. - settings
pointer-events: none
on the dragged element - this just seems to remove it from thedocument.querySelectorAll ":hover"
list
I want to avoid searching through all items in a list to see if my mouse cursor is inside their boundaries if possible, because I suspect it will be a huge performance hit.