From a7d9f7dcd534277a84f67fa35c767ac438e0c2e9 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Fri, 2 Jan 2015 11:44:35 -0800 Subject: [PATCH] Fixed broken defaultZoomLevel and homeFillsViewer options --- src/viewport.js | 11 ++++++++++- test/demo/collections/main.js | 7 ++++++- test/viewport.js | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/viewport.js b/src/viewport.js index 77893189..44654f7e 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -230,7 +230,16 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{ * @function */ getHomeBounds: function() { - return this.homeBounds.clone(); + var center = this.homeBounds.getCenter( ), + width = 1.0 / this.getHomeZoom( ), + height = width / this.getAspectRatio(); + + return new $.Rect( + center.x - ( width / 2.0 ), + center.y - ( height / 2.0 ), + width, + height + ); }, /** diff --git a/test/demo/collections/main.js b/test/demo/collections/main.js index a792131d..83563085 100644 --- a/test/demo/collections/main.js +++ b/test/demo/collections/main.js @@ -17,6 +17,8 @@ zoomPerScroll: 1.02, showNavigator: testNavigator, useCanvas: true, + // defaultZoomLevel: 2, + // homeFillsViewer: true, // sequenceMode: true, // showReferenceStrip: true, // referenceStripScroll: 'vertical', @@ -70,7 +72,10 @@ } ]; - // config.tileSources = highsmith; + // config.tileSources = { + // tileSource: highsmith, + // width: 1 + // }; } if (testOverlays) { diff --git a/test/viewport.js b/test/viewport.js index bd30b2ba..769f934f 100644 --- a/test/viewport.js +++ b/test/viewport.js @@ -207,7 +207,7 @@ method: 'getHomeBounds', processExpected: function(level, expected) { // Have to special case this to avoid dividing by 0 - if(level === 0){ + if(level === -1 || level === 0){ expected = new OpenSeadragon.Rect(0, 0, 1, 1); } else { var sideLength = 1.0 / viewer.defaultZoomLevel; // it's a square in this case