Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-16-2011, 08:21 PM   PM User | #1
sven_paul
New Coder

 
Join Date: Feb 2011
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
sven_paul is an unknown quantity at this point
{Jquery} On mousedown disable timer, Possible?

Hi i have a timer which is set to execute a function every 3 seconds, id like to know if it's possible to diable the timer function every time the mousBtn is held (mousedown), and on mouseup enable the timer again, and how can i do this?

Code:
var timerFunc = setInterval( loadPos, 3000 );
sven_paul is offline   Reply With Quote
Old 04-16-2011, 08:58 PM   PM User | #2
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
Quote:
Originally Posted by sven_paul View Post
Hi i have a timer which is set to execute a function every 3 seconds, id like to know if it's possible to diable the timer function every time the mousBtn is held (mousedown), and on mouseup enable the timer again, and how can i do this?

Code:
var timerFunc = setInterval( loadPos, 3000 );
not tested:
Code:
var timer = null;
$('button selector').mouseup(function(){
   timer = setInterval( loadPos, 3000 );
});
$('button selector').mousedown(function(){
   if(timer){
      clearInterval(timer);
   }
});
best regards
oesxyl is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:46 PM.


Advertisement
Log in to turn off these ads.