Reputation: 91
I am using the following snippet to resize a canvas element successfully. I need it to resize a canvas element on page load and not require user interaction to fire the windowResize()
function.
(function($){
$(window).resize(function(){
windowResize();
});
})(jQuery);
function windowResize(){
stage.canvas.width = window.innerWidth;
stage.canvas.height = window.innerHeight;
var test = (window.innerHeight/500)*1;
exportRoot.scaleX = exportRoot.scaleY = test;
}
Upvotes: 1
Views: 205
Reputation:
Just modify your snippet to:
$(window).on('resize load', windowResize);
This will invoke windowResize()
at both load and resize.
Upvotes: 0
Reputation: 105015
Just call windowResize in jQuery-loaded.
$(function(){
function windowResize(){
stage.canvas.width = window.innerWidth;
stage.canvas.height = window.innerHeight;
var test = (window.innerHeight/500)*1;
exportRoot.scaleX = exportRoot.scaleY = test;
}
....
$(window).resize(function(){ windowResize(); });
windowResize();
}); // end $(function(){});
Upvotes: 1