diff --git a/src/overlay.js b/src/overlay.js index c59d8c35..0bdbbf34 100644 --- a/src/overlay.js +++ b/src/overlay.js @@ -106,7 +106,7 @@ placement: placement }; } - + this.element = options.element; this.scales = options.location instanceof $.Rect; this.bounds = new $.Rect( diff --git a/src/viewer.js b/src/viewer.js index 3fbb9e06..d522c077 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -504,11 +504,6 @@ $.Viewer = function( options ) { }); } - // Create initial overlays - for ( i = 0; i < this.overlays.length; i++ ) { - this.currentOverlays[ i ] = getOverlayObject( this, this.overlays[ i ] ); - } - // Open initial tilesources if ( this.tileSources ) { this.open( this.tileSources ); @@ -606,6 +601,11 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, source = source.tileSource; } + // Global overlays + for ( var i = 0; i < _this.overlays.length; i++ ) { + _this.currentOverlays[ i ] = getOverlayObject( _this, _this.overlays[ i ] ); + } + /** * Raised when the viewer has opened and loaded one or more TileSources. * @@ -683,6 +683,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, } }; + // TileSources for (var i = 0; i < tileSources.length; i++) { doOne(tileSources[i]); } diff --git a/src/world.js b/src/world.js index 66b25f3c..3b39861f 100644 --- a/src/world.js +++ b/src/world.js @@ -272,7 +272,7 @@ $.extend( $.World.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.W var box; for ( var i = 1; i < this._items.length; i++ ) { box = this._items[i].getWorldBounds(); - this._contentFactor = Math.max(this._contentFactor, this._items[i].getContentSize().x / bounds.width); + this._contentFactor = Math.max(this._contentFactor, this._items[i].getContentSize().x / box.width); left = Math.min( left, box.x ); top = Math.min( top, box.y ); right = Math.max( right, box.x + box.width ); diff --git a/test/basic.js b/test/basic.js index 4a7892d9..9ef6ee8d 100644 --- a/test/basic.js +++ b/test/basic.js @@ -95,7 +95,8 @@ var panHandler = function() { viewer.removeHandler('animation-finish', panHandler); center = viewport.getCenter(); - ok(center.x === 0.1 && center.y === 0.1, 'Panned correctly'); + Util.assessNumericValue(center.x, 0.1, 0.00001, 'panned horizontally'); + Util.assessNumericValue(center.y, 0.1, 0.00001, 'panned vertically'); start(); }; @@ -260,9 +261,8 @@ viewer.removeHandler('close', closeHandler); ok(!viewer.source, 'no source'); ok(true, 'Close event was sent'); - ok(!viewer._updateRequestId, 'timer is off'); setTimeout(function() { - ok(!viewer._updateRequestId, 'timer is still off'); + ok(!viewer._updateRequestId, 'timer is off'); start(); }, 100); }; diff --git a/test/demo/collections/index.html b/test/demo/collections/index.html index 9afe8907..fc1766cc 100644 --- a/test/demo/collections/index.html +++ b/test/demo/collections/index.html @@ -14,6 +14,10 @@ height: 100%; } + .openseadragon-overlay { + background-color: rgba(255, 0, 0, 0.3); + } + diff --git a/test/demo/collections/main.js b/test/demo/collections/main.js index 68920e03..30992342 100644 --- a/test/demo/collections/main.js +++ b/test/demo/collections/main.js @@ -27,9 +27,27 @@ showNavigator: true, id: "contentDiv", tileSources: tileSources, - prefixUrl: "../../../build/openseadragon/images/" + prefixUrl: "../../../build/openseadragon/images/", + overlays: [ { + px: 13, + py: 120, + width: 124, + height: 132, + id: "overlay" + }, { + px: 400, + py: 500, + width: 400, + height: 400, + id: "fixed-overlay", + placement: "TOP_LEFT" + } ] } ); + this.viewer.addHandler( "open", function() { + // console.log(self.viewer.viewport.contentSize); + }); + // this.crossTest3(); }, diff --git a/test/multi-image.js b/test/multi-image.js index 5559f110..4975b9b4 100644 --- a/test/multi-image.js +++ b/test/multi-image.js @@ -144,7 +144,7 @@ viewer.addHandler( "add-item-failed", function addItemFailedHandler( event ) { viewer.removeHandler( "add-item-failed", addItemFailedHandler ); - equal( event.message, "[Viewer.addTiledImage] Sequences can not be added." ); + equal( event.message, "[Viewer.addTiledImage] Sequences can not be added; add them one at a time instead." ); equal( event.options, options, "Item failed event should give the options." ); start(); } );