From e02a2d55ccf7ce8b2914132f58dd274b3a8d9c99 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Mon, 10 Nov 2014 15:53:38 -0800 Subject: [PATCH] Fixed issue with navigator size when viewer is zero size to start --- src/navigator.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/navigator.js b/src/navigator.js index 2cadc03f..e320fb68 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -309,16 +309,22 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /* viewerSize = $.getElementSize( this.viewer.element ); if ( !viewerSize.equals( this.oldViewerSize ) ) { this.oldViewerSize = viewerSize; - if ( this.maintainSizeRatio ) { + + if ( this.maintainSizeRatio || !this.elementArea) { newWidth = viewerSize.x * this.sizeRatio; newHeight = viewerSize.y * this.sizeRatio; - } - else { + } else { newWidth = Math.sqrt(this.elementArea * (viewerSize.x / viewerSize.y)); newHeight = this.elementArea / newWidth; } + this.element.style.width = Math.round( newWidth ) + 'px'; this.element.style.height = Math.round( newHeight ) + 'px'; + + if (!this.elementArea) { + this.elementArea = newWidth * newHeight; + } + this.updateSize(); }