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/
You need to return false
in your mousedown
handler, to prevent the default action of selecting text upon drag.
Updated fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With