please merge updatePreviewMetrics into updatePreview.  If you do that, then you won't need this.container. You can just use local variables conainerWidth, containerHeight and containerAspect within the combined function.  I think that would simplify this code considerably.