#686 prevent redraw lock on error

This commit is contained in:
Leo Horie 2015-06-23 13:43:54 -04:00
parent 04911d38a5
commit 505d7b930d
3 changed files with 18 additions and 14 deletions

1
.gitignore vendored
View file

@ -1,2 +1 @@
node_modules
archive

View file

@ -33,7 +33,8 @@ module.exports = function(grunt) {
"mithril",
"mithril.computation",
"mithril.deferred",
"mithril.module",
"mithril.mount",
"mithril.component",
"mithril.prop",
"mithril.redraw",
"mithril.render",

View file

@ -615,21 +615,25 @@ var m = (function app(window, undefined) {
if (redrawing) return;
redrawing = true;
if (force) forcing = true;
//lastRedrawId is a positive number if a second redraw is requested before the next animation frame
//lastRedrawID is null if it's the first redraw and not an event handler
if (lastRedrawId && force !== true) {
//when setTimeout: only reschedule redraw if time between now and previous redraw is bigger than a frame, otherwise keep currently scheduled timeout
//when rAF: always reschedule redraw
if ($requestAnimationFrame === window.requestAnimationFrame || new Date - lastRedrawCallTime > FRAME_BUDGET) {
if (lastRedrawId > 0) $cancelAnimationFrame(lastRedrawId);
lastRedrawId = $requestAnimationFrame(redraw, FRAME_BUDGET);
try {
//lastRedrawId is a positive number if a second redraw is requested before the next animation frame
//lastRedrawID is null if it's the first redraw and not an event handler
if (lastRedrawId && force !== true) {
//when setTimeout: only reschedule redraw if time between now and previous redraw is bigger than a frame, otherwise keep currently scheduled timeout
//when rAF: always reschedule redraw
if ($requestAnimationFrame === window.requestAnimationFrame || new Date - lastRedrawCallTime > FRAME_BUDGET) {
if (lastRedrawId > 0) $cancelAnimationFrame(lastRedrawId);
lastRedrawId = $requestAnimationFrame(redraw, FRAME_BUDGET);
}
}
else {
redraw();
lastRedrawId = $requestAnimationFrame(function() { lastRedrawId = null; }, FRAME_BUDGET);
}
}
else {
redraw();
lastRedrawId = $requestAnimationFrame(function() { lastRedrawId = null; }, FRAME_BUDGET);
finally {
redrawing = forcing = false;
}
redrawing = forcing = false;
};
m.redraw.strategy = m.prop();
function redraw() {