HTML5 Canvas autoresize
While developing the HTML5 DICOM Viewer I got some problems while designing the UI in HTML.
One of those problems was how to manage the canvas resize according to the browser size.
At least for me it wasn't so much trivial :) so I decided to post it so it could be useful for someone else.
Basically what you have to do is to bind the onresize event to your body, once you catch the event you just need to resize the canvas using window.innerWidth and window.innerHeight.
I just needed to add little functionality to preserve aspect ratio and manage the toolbar div.
If you want to try it just click here or check the following video to see how it works:
2 comments
What Mr.doob said + fallback to javascript resizing w/o the canvas element for all the browsers w/o html5 / css3 support.
Feel free to contact me using mail or contact form
http://slides.html5rocks.com/#css-background ^^