javascript - Simulating dragging for DIV, issue with fast moving mouse pointer -
i need simulate dragging effect, when user click
, kept hold
mouse on div, should re-positioned accordingly mouse coordinates (following mouse).
this script works fine:
http://jsbin.com/vurumupoqu/1/
except when user click , hold very near edge of div , move fast , far away mouse outside div, in case not being dragged @ all.
i have tried several option mouseleave
, mouseout
not success.
i need div being dragged if user move fast mouse when key hold anywhere on page.
i know:
- how fix issue? (i meanly target latest chrome , firefix).
- could better option using html5 drag? if yes why?
bind mousemove
event handler document
instead of element itself:
document.addeventlistener('mousemove', function (event) { console.log('+ mousemove') this.logicdrag(); }.bind(this));
http://jsbin.com/deyiwaqeqa/2/
explanation
a mousemove
event not triggered every pixel when move mouse around. means mouse might have left #target
- before #target
has been moved match new mouse position.
Comments
Post a Comment