May 9, 2013
If mouse up then call the function
User2156494’s Questions:
I have the following code that calls a function. However, I would like the function to be called only on the event of a Mouse Up
.
positionMenu : function(){
if (positionMenuInvalidated) return;
positionMenuInvalidated = true;
setTimeout(_positionMenuNow,1); }
The _positionMenuNow
which is called in setTimeout
should happen only in the event of a mouse up. How can this condition be satisfied ?
I don’t think its a good idea to check whether the mouse is up or not while executing the timeout. Instead its better if you trigger the timeout after the mouseup
has been triggered.
$('body').on('mouseup', function() {
setTimeOut("_positionMenu()", 1000);