In the case where an element is hidden, calling this.element.offsetWidth will return 0. For example, when I'm rending an avatar to a tab view that isn't shown, when I navigate to the tab view the canvas has the width and height attributes of 0. I'm not sure what the best fix is, but this is working for me as a fallback as I have the element styled:
Avatar.prototype.init = function(){
this.width = parseInt(this.element.offsetWidth || this.element.style.width, 10);
this.height = parseInt(this.element.offsetHeight || this.element.style.height, 10);
Thoughts?
In the case where an element is hidden, calling
this.element.offsetWidthwill return 0. For example, when I'm rending an avatar to a tab view that isn't shown, when I navigate to the tab view the canvas has the width and height attributes of 0. I'm not sure what the best fix is, but this is working for me as a fallback as I have the element styled:Thoughts?