Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pause a setTimeout call? [duplicate]

Possible Duplicate:
javascript: pause setTimeout();

Im using jQuery and working on a notification system for my site. The notifications automatically fadeout using the setTimeout function.

How can i stop the timer of the setTimeout call?

For example i would like to pause the setTimeout call while the mouse is over the notification and continue the count down mouseout...

I googled "pause setTimeout" with no luck.

Im currently clearing the setTimeout call with clearTimeout and at same time fading out the notification on mouseout but it would be nice to have that pause effect.

Any ideas?

like image 453
Pablo Avatar asked Apr 12 '10 22:04

Pablo


1 Answers

Try this.

var myTimeOut;
$(someElement).mouseout( function () {
  myTimeOut = setTimeout("mytimeoutfunction()", 5000)
});

$(someElement).mouseover( function () {
  clearTimeout(myTimeOut);
});
like image 104
John Hartsock Avatar answered Sep 24 '22 18:09

John Hartsock