Skip to content

Commit

Permalink
Merge pull request ejci#31 from jorygraham/master
Browse files Browse the repository at this point in the history
Save animation timeout IDs, clear them on reset
  • Loading branch information
ejci committed Jan 14, 2014
2 parents 65cd9f7 + d4cc9df commit ca5e304
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions favico.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
animation : 'slide',
elementId : false
};
var _opt, _orig, _h, _w, _canvas, _context, _img, _ready, _lastBadge, _running, _readyCb, _stop, _browser;
var _opt, _orig, _h, _w, _canvas, _context, _img, _ready, _lastBadge, _running, _readyCb, _stop, _browser, _animTimeout, _drawTimeout;

_browser = {};
_browser.ff = (/firefox/i.test(navigator.userAgent.toLowerCase()));
Expand Down Expand Up @@ -144,6 +144,8 @@
link.setIcon(_canvas);
//webcam('stop');
//video('stop');
window.clearTimeout(_animTimeout);
window.clearTimeout(_drawTimeout);
};
/**
* Start animation
Expand Down Expand Up @@ -438,7 +440,7 @@
} catch(e) {

}
setTimeout(drawVideo, animation.duration, video);
_drawTimeout = setTimeout(drawVideo, animation.duration, video);
link.setIcon(_canvas);
}

Expand Down Expand Up @@ -786,7 +788,7 @@
};
if ((step < animationType.length) && (step >= 0)) {
type[_opt.type](merge(opt, animationType[step]));
setTimeout(function() {
_animTimeout = setTimeout(function() {
if (revert) {
step = step - 1;
} else {
Expand Down

0 comments on commit ca5e304

Please sign in to comment.