Permalink
Browse files

Fix cancel() function incorrect behaviour that prevented the loop to …

…be effectively canceled
  • Loading branch information...
1 parent a39bb96 commit e7a03b3b32bbea95669eacb08d45ad9cfa7b8384 @jorgemanrubia jorgemanrubia committed with Jul 12, 2010
Showing with 4 additions and 2 deletions.
  1. +4 −2 jquery.periodic.js
View
6 jquery.periodic.js
@@ -45,7 +45,8 @@ jQuery.periodic = function (options, callback) {
increment();
// queue up the next run
- run();
+ if(settings.tid)
+ run();
}, settings.cur_period);
}
@@ -81,6 +82,7 @@ jQuery.periodic = function (options, callback) {
function cancel() {
clearTimeout(settings.tid);
+ settings.tid = null;
}
// other functions we might want to implement
@@ -94,4 +96,4 @@ jQuery.periodic.defaults = {
max_period : 1800000, // 30 min.
decay : 1.5, // time period multiplier
on_max : undefined // called if max_period is reached
-};
+};

0 comments on commit e7a03b3

Please sign in to comment.