{"action":"opened","issue":{"url":"https://api.github.com/repos/kripken/emscripten/issues/3206","labels_url":"https://api.github.com/repos/kripken/emscripten/issues/3206/labels{/name}","comments_url":"https://api.github.com/repos/kripken/emscripten/issues/3206/comments","events_url":"https://api.github.com/repos/kripken/emscripten/issues/3206/events","html_url":"https://github.com/kripken/emscripten/issues/3206","id":58462972,"number":3206,"title":"Difficulty handling Emscripten canvas scaling","user":{"login":"jgranick","id":833997,"avatar_url":"https://avatars.githubusercontent.com/u/833997?v=3","gravatar_id":"","url":"https://api.github.com/users/jgranick","html_url":"https://github.com/jgranick","followers_url":"https://api.github.com/users/jgranick/followers","following_url":"https://api.github.com/users/jgranick/following{/other_user}","gists_url":"https://api.github.com/users/jgranick/gists{/gist_id}","starred_url":"https://api.github.com/users/jgranick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgranick/subscriptions","organizations_url":"https://api.github.com/users/jgranick/orgs","repos_url":"https://api.github.com/users/jgranick/repos","events_url":"https://api.github.com/users/jgranick/events{/privacy}","received_events_url":"https://api.github.com/users/jgranick/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-21T15:31:02Z","updated_at":"2015-02-21T15:31:02Z","closed_at":null,"body":"When I implemented Emscripten support in the past, I was able to resize the canvas element in HTML, and handle resize events within my \"native\" code. However, it seems that Emscripten content now wrestles with my code changes on resize, forcing itself back to an original (or different) size.\r\n\r\nFor example, this code is meant to size the canvas to whatever size the DIV element it is in is sized to:\r\n\r\n\t\tvar container = document.getElementById (\"content\");\r\n\t\tModule.canvas.width = container.clientWidth;\r\n\t\tModule.canvas.height = container.clientHeight;\r\n\t\t\r\n\t\twindow.addEventListener (\"resize\", function (e) {\r\n\t\t\t\r\n\t\t\tModule.canvas.width = container.clientWidth;\r\n\t\t\tModule.canvas.height = container.clientHeight;\r\n\t\t\t\r\n\t\t}, true);\r\n\r\nBy default, when targeting HTML5, OpenFL projects usually do one of two behaviors by default. Either the window size is set to 100%, so it handles the DOM element parent as the maximum. This allows for a custom HTML template to constrain or expand the content by resizing that DIV, and the project takes up that full space accordingly.\r\n\r\nThe second is when you specify an exact size. Due to mobile device screen sizes varying so much, the default template for this will stretch to match the parent DIV size as well, but will maintain aspect ratio, and automatically allow letterboxing. This preserves the original pixel size, but uses CSS to improve usability.\r\n\r\nAnyway, both of these methods allow the project to constrain to it's parent DOM element, with some scripting to handle the resize. I have tried to implement some of this outside of Emscripten in the page, but to no avail.\r\n\r\nThis used to work with Emscripten, but this was before the SDL2 port. Is there some way I can \"turn off\" Emscripten canvas sizing after the initial size, or is there a way within C++ that I could size relative to the parent DOM element, like I'm hoping to? It's sort of simulated fullscreen.\r\n\r\nThank you!\r\n"}}