Skip to content

Commit

Permalink
Slightly more responsive to window size changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sz3 committed Jun 12, 2021
1 parent 9e8e552 commit d0dffa2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
7 changes: 1 addition & 6 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -288,17 +288,12 @@
<a id="invisible_click" href="javascript:;" onclick="Main.clickNav()"></a>

<script type="text/javascript">
// reset zoom
document.body.style.zoom = (window.innerWidth / window.outerWidth);

var canvas = document.getElementById('canvas');
var width = window.outerWidth;
var height = window.outerHeight;

var Module = {};
Module.canvas = canvas;
Module.onRuntimeInitialized = () => {
Main.run(canvas, width, height);
Main.init();
Main.nextFrame();
};
</script>
Expand Down
20 changes: 14 additions & 6 deletions web/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ var _renderTime = 0;
function toggleFullscreen()
{
if (document.fullscreenElement) {
document.exitFullscreen();
return document.exitFullscreen();
}
else {
document.documentElement.requestFullscreen();
return document.documentElement.requestFullscreen();
}
}

Expand All @@ -39,18 +39,26 @@ function importFile(f)

// public interface
return {
run : function(canvas, width, height)
init : function(canvas)
{
console.log("init for canvas " + canvas);

Module._initialize_GL(1040, 1040);
Main.resize();
},

resize : function()
{
// reset zoom
document.body.style.zoom = (window.innerWidth / window.outerWidth);
var canvas = document.getElementById('canvas');
var width = window.outerWidth;
var height = window.outerHeight;
Main.scaleCanvas(canvas, width, height);
Main.alignInvisibleClick(canvas);
},

toggleFullscreen : function()
{
toggleFullscreen();
toggleFullscreen().then(Main.resize);
},

scaleCanvas : function(canvas, width, height)
Expand Down

0 comments on commit d0dffa2

Please sign in to comment.