javascript - Detecting drag position on an element -
i building wysiwyg editor build html emails. want able add row layouts editor drag , drop.
if row dragged , dropped above halfway point of drop target, want prepend row before drop target; , if dropped below halfway point, want append row after drop target.
is there way this?
you can use getboundingclientrect()
coordinates of element while mouse button pressed , moving this
element.onclick = function() { element.onmousemove = function() { var x1 = element.getboundingclientrect().left, x2 = x1 + element.getboundingclientrect().width, y1 = element.getboundingclientrect().top, y2 = element.getboundingclientrect().height; } }
and can whatever these coordinates.
Comments
Post a Comment