Reputation: 1450
I'm trying to track the mouse position while I click and drag an a[href]
value to the bookmarks bar (it's for a bookmarklet). It seems to stop tracking a few seconds after I start dragging.
Code is below.
var isDragging = false;
$('a#dragthis')
.mousedown(function() {
$(window).mousemove(function(e) {
isDragging = true;
var x = e.pageX;
var y = e.pageY;
console.log(x + "|" + y);
});
});
Here is a jsFiddle example: http://jsfiddle.net/GZpHP/
Upvotes: 7
Views: 6157
Reputation: 37
I wanted the same and ended up utilizing ondragstart
and ondrop
to log and then handle mouse position upon the drop event.
Its not perfect but it does the job.
Upvotes: 0
Reputation: 43228
You need to return false
in your mousedown
handler, to prevent the default action of selecting text upon drag.
Upvotes: 2