I have the following code snippets
$(document).mousedown(function(event) {
doSomething();
}
I can capture the mousedown
event successfully.
I am trying to do the following:
mousedown
eventSomething like
var mouseStillDown = false;
$(document).mousedown(function(event) {
mouseStillDown = true;
doSomething();
});
function doSomething() {
if (!mouseStillDown) { return; } // we could have come back from
// SetInterval and the mouse is no longer down
// do something
if (mouseStillDown) { setInterval("doSomething", 100); }
}
$(document).mouseup(function(event) {
mouseStillDown = false;
});
var int00; // declared here to make it visible to clearInterval.
$('#trigger').mousedown(function(){
int00 = setInterval(function() { repeatingfunction(); }, 50);
}).mouseup(function() {
clearInterval(int00);
});
function repeatingfunction() {
// This will repeat //
}
You can also put a clearInterval
on the mouseleave
event.
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