Fixed issue with navigator size when viewer is zero size to start

This commit is contained in:
Ian Gilman 2014-11-10 15:53:38 -08:00
parent 9ebdaee326
commit e02a2d55cc

View File

@ -309,16 +309,22 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
viewerSize = $.getElementSize( this.viewer.element ); viewerSize = $.getElementSize( this.viewer.element );
if ( !viewerSize.equals( this.oldViewerSize ) ) { if ( !viewerSize.equals( this.oldViewerSize ) ) {
this.oldViewerSize = viewerSize; this.oldViewerSize = viewerSize;
if ( this.maintainSizeRatio ) {
if ( this.maintainSizeRatio || !this.elementArea) {
newWidth = viewerSize.x * this.sizeRatio; newWidth = viewerSize.x * this.sizeRatio;
newHeight = viewerSize.y * this.sizeRatio; newHeight = viewerSize.y * this.sizeRatio;
} } else {
else {
newWidth = Math.sqrt(this.elementArea * (viewerSize.x / viewerSize.y)); newWidth = Math.sqrt(this.elementArea * (viewerSize.x / viewerSize.y));
newHeight = this.elementArea / newWidth; newHeight = this.elementArea / newWidth;
} }
this.element.style.width = Math.round( newWidth ) + 'px'; this.element.style.width = Math.round( newWidth ) + 'px';
this.element.style.height = Math.round( newHeight ) + 'px'; this.element.style.height = Math.round( newHeight ) + 'px';
if (!this.elementArea) {
this.elementArea = newWidth * newHeight;
}
this.updateSize(); this.updateSize();
} }