material-avatar
material-avatar copied to clipboard
Issue with offsetWidth/offsetHeight
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?
this wouldn't work for dynamically sized objects on show though, ie some one was using a percent value or a em value. would it be possible to create a canvas on-resize binding an the adjust the height and width then?
Yeah I definitely think that could help. It would be nice if it could somehow wait to draw until the canvas is actually visible. Maybe keep requesting animations frames while offsetWidth/height is 0?