diff --git a/.gitignore b/.gitignore index aeab5a02..3c3629e6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ node_modules -archive diff --git a/Gruntfile.js b/Gruntfile.js index 9bad17f0..ae789912 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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", diff --git a/mithril.js b/mithril.js index 3e4c0867..eba9b40c 100644 --- a/mithril.js +++ b/mithril.js @@ -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() {