on mouse down register x y

var clicking = false;

$('.selector').mousedown(function(){
clicking = true;
$('.clickstatus').text('mousedown');
});

$(document).mouseup(function(){
clicking = false;
$('.clickstatus').text('mouseup');
$('.movestatus').text('click released, no more move event');
})

$('.selector').mousemove(function(){
if(clicking == false) return;

// Mouse click + moving logic here
$('.movestatus').text('mouse moving');
});

Tags: