diff Platforms/Wasm/wasm-viewport.ts @ 420:8bf717c4e497

canvas size is now defined by the parent div size
author am@osimis.io
date Mon, 19 Nov 2018 12:45:37 +0100
parents 8716176ff7f0
children 59b4afa92dee 5055031f4a06
line wrap: on
line diff
--- a/Platforms/Wasm/wasm-viewport.ts	Thu Nov 15 18:41:50 2018 +0100
+++ b/Platforms/Wasm/wasm-viewport.ts	Mon Nov 19 12:45:37 2018 +0100
@@ -137,12 +137,9 @@
         this.imageData_ = null;
       }
       
-      // width/height can be defined in percent of window width/height through html attributes like data-width-ratio="50" and data-height-ratio="20"
-      var widthRatio = Number(this.htmlCanvas_.dataset["widthRatio"]) || 100;
-      var heightRatio = Number(this.htmlCanvas_.dataset["heightRatio"]) || 100;
-
-      this.htmlCanvas_.width = window.innerWidth * (widthRatio / 100);  
-      this.htmlCanvas_.height = window.innerHeight * (heightRatio / 100);
+      // width/height is defined by the parent width/height
+      this.htmlCanvas_.width = this.htmlCanvas_.parentElement.offsetWidth;  
+      this.htmlCanvas_.height = this.htmlCanvas_.parentElement.offsetHeight;  
 
       console.log("resizing WasmViewport: ", this.htmlCanvas_.width, "x", this.htmlCanvas_.height);