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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -