on master help sign in
Get rid of memory leak caused by creating tons of canvases.
a764f68evancz
runtime/Render/Collage.js+8−1
@@ -189,7 +189,14 @@ function render(model) {
189}
189}
190
190
191function update(node, oldModel, newModel) {
191function update(node, oldModel, newModel) {
192+ if (!node.getContext) {
192− node.parentNode.replaceChild(render(newModel), node);
193+ return node.parentNode.replaceChild(render(newModel), node);
194+ }
195+ var ctx = node.getContext('2d');
196+ var w = newModel.w, h = newModel.h;
197+ ctx.clearRect(-w/2, -h/2, w, h);
198+ function redo() { renderForms( this, ctx, newModel.forms ); }
199+ renderForms( redo, ctx, newModel.forms );
193}
200}
194
201
195return { render:render, update:update };
202return { render:render, update:update };