Hey all, I want to resize an element but not as often as I currently do it.
Right now I have a project with an html element that gets resized on every frame and it runs on every update.
game.gui.TextArea = me.Renderable.extend({
init: function() {
this.textarea = document.createElement('textarea');
this.textarea.id = 'textHistory';
this.textarea.readOnly = "true";
this.textarea.disabled = "true";
me.video.getWrapper().appendChild(this.textarea);
},
update: function() {
videoPos = me.video.getPos();
this.textarea.style = 'width:' + (window.innerWidth - videoPos.width) + 'px; height:' + videoPos.height + 'px;';
}
});
I'm concerned about this, this code will run way more often than it needs. Not sure about the performance impact but it only needs to run when the window size is updated. Is there a way I can piggyback on any melonjs functions that resize the canvas and only run it then?