From 66ebb9fe0a7c4901b7bd9f87667d0b0d1d1e0930 Mon Sep 17 00:00:00 2001 From: "Sean S. LeBlanc" Date: Wed, 22 Apr 2020 00:39:42 -0400 Subject: [PATCH] refactor resize --- WebGLTemplates/BetterMinimal/index.html | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/WebGLTemplates/BetterMinimal/index.html b/WebGLTemplates/BetterMinimal/index.html index 7807807..9d3745b 100644 --- a/WebGLTemplates/BetterMinimal/index.html +++ b/WebGLTemplates/BetterMinimal/index.html @@ -1,5 +1,6 @@ + @@ -10,10 +11,11 @@ var scaleToFit; try { scaleToFit = !!JSON.parse("%UNITY_CUSTOM_SCALE_TO_FIT%"); - } catch(e) { + } catch (e) { scaleToFit = true; } - window.onresize = function() { + + function onResize() { var canvas = gameInstance.Module.canvas; var container = gameInstance.container; var w; @@ -39,6 +41,7 @@ container.style.top = Math.floor((window.innerHeight - h) / 2) + "px"; container.style.left = Math.floor((window.innerWidth - w) / 2) + "px"; } + window.addEventListener('resize', onResize); - +
+