on master help sign in
Make sure that screen resize is registered on initialization
c37f30fEvan Czaplicki
runtime/Init.js+11−6
@@ -157,20 +157,25 @@ function initGraphics(elm, Module) {
157 }
157 }
158 var currentScene = signalGraph.value;
158 var currentScene = signalGraph.value;
159
159
160− // Add the currentScene to the DOM
160+ // Add the currentScene to the DOM
161 var Render = ElmRuntime.use(ElmRuntime.Render.Element);
161 var Render = ElmRuntime.use(ElmRuntime.Render.Element);
162 elm.node.appendChild(Render.render(currentScene));
162 elm.node.appendChild(Render.render(currentScene));
163− if (elm.Native.Window) elm.Native.Window.resizeIfNeeded();
164
163
165 // set up updates so that the DOM is adjusted as necessary.
164 // set up updates so that the DOM is adjusted as necessary.
166 function domUpdate(newScene, currentScene) {
165 function domUpdate(newScene, currentScene) {
167 ElmRuntime.draw(function(_) {
166 ElmRuntime.draw(function(_) {
168− Render.update(elm.node.firstChild, currentScene, newScene);
167+ Render.update(elm.node.firstChild, currentScene, newScene);
169− if (elm.Native.Window) elm.Native.Window.resizeIfNeeded();
168+ if (elm.Native.Window) elm.Native.Window.resizeIfNeeded();
170− });
169+ });
171 return newScene;
170 return newScene;
172 }
171 }
173− return A3(Signal.foldp, F2(domUpdate), currentScene, signalGraph);
172+ var renderer = A3(Signal.foldp, F2(domUpdate), currentScene, signalGraph);
173+
174+ // must check for resize after 'renderer' is created so
175+ // that changes show up.
176+ if (elm.Native.Window) elm.Native.Window.resizeIfNeeded();
177+
178+ return renderer;
174}
179}
175
180
176}());
181}());