Skip to content

Commit

Permalink
Fix the way the site editor resizes on the web (#194)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael X. Grey <[email protected]>
  • Loading branch information
mxgrey authored Dec 27, 2023
1 parent 7289f55 commit 153c84f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Make sure you install rust from the main rust website. Cargo should take care of
These are only needed if you're going to build a WebAssembly binary:
```bash
$ sudo apt install binaryen
$ cargo install wasm-bindgen-cli basic-http-server
$ cargo install wasm-bindgen-cli@0.2.84 basic-http-server
$ rustup target add wasm32-unknown-unknown
```

Expand Down
25 changes: 7 additions & 18 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,13 @@
</head>
<body>
<canvas id="rmf_site_editor_canvas">
<script type="module">
import init from "./librmf_site_editor.js";
document.addEventListener('contextmenu', function(evt) { evt.preventDefault(); });
init("./librmf_site_editor_bg_optimized.wasm").then(function (wasm) {
wasm.run_js();
});
</script>
</canvas>
<script type="module">
import init from "./librmf_site_editor.js";

document.addEventListener('contextmenu', function(evt) { evt.preventDefault(); });
resize_canvas();
window.addEventListener('resize', resize_canvas);

function resize_canvas() {
let canvas = document.getElementById("rmf_site_editor_canvas");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
console.log('canvas size: ' + canvas.width + ' ' + canvas.height);
}

init("./librmf_site_editor_bg_optimized.wasm").then(function (wasm) {
wasm.run_js();
});
</script>
</body>
</html>

0 comments on commit 153c84f

Please sign in to comment.