Navigator now works with multiple images

This commit is contained in:
Ian Gilman 2014-09-23 16:15:03 -07:00
parent 63996a7d92
commit e02209092c
3 changed files with 32 additions and 12 deletions

View File

@ -83,7 +83,7 @@ $.Navigator = function( options ){
options.controlOptions.width = options.width;
}
}
} else {
this.element = document.getElementById( options.id );
options.controlOptions = {
@ -216,21 +216,25 @@ $.Navigator = function( options ){
unneededElement.parentNode.removeChild(unneededElement);
}
if (options.navigatorRotate)
{
if (options.navigatorRotate) {
options.viewer.addHandler("rotate", function (args) {
_setTransformRotate(_this.displayRegionContainer, args.degrees);
_setTransformRotate(_this.displayRegion, -args.degrees);
_this.viewport.setRotation(args.degrees);
});
}
this.addHandler("reset-size", function() {
if (_this.viewport) {
_this.viewport.goHome(true);
}
});
};
$.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /** @lends OpenSeadragon.Navigator.prototype */{
/**
* Used to notify the navigator when its size has changed.
* Used to notify the navigator when its size has changed.
* Especially useful when {@link OpenSeadragon.Options}.navigatorAutoResize is set to false and the navigator is resizable.
* @function
*/
@ -313,7 +317,7 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
},
open: function( source ) {
open: function(source, options) {
this.updateSize();
var containerSize = this.viewer.viewport.containerSize.times( this.sizeRatio );
var ts = source.getTileSize(source.maxLevel);
@ -322,7 +326,7 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
} else {
this.minPixelRatio = this.viewer.minPixelRatio;
}
return $.Viewer.prototype.open.apply( this, [ source ] );
return $.Viewer.prototype.open.apply( this, [source, options] );
}
});

View File

@ -1112,6 +1112,14 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
_this.world.addItem( tiledImage, {
index: options.index
});
if (_this.navigator) {
var optionsClone = $.extend({}, options, {
tileSource: tileSource
});
_this.navigator.addTiledImage(optionsClone);
}
}, function( event ) {
event.options = options;
raiseAddItemFailed(event);
@ -1956,9 +1964,7 @@ function openTileSource( viewer, source, options ) {
if ( _this.showNavigator && !_this.collectionMode ){
// Note: By passing the fully parsed source, the navigator doesn't
// have to load it again.
if ( _this.navigator ) {
_this.navigator.open( source );
} else {
if (!_this.navigator) {
_this.navigator = new $.Navigator({
id: _this.navigatorId,
position: _this.navigatorPosition,
@ -1969,13 +1975,14 @@ function openTileSource( viewer, source, options ) {
width: _this.navigatorWidth,
height: _this.navigatorHeight,
autoResize: _this.navigatorAutoResize,
tileSources: source,
tileHost: _this.tileHost,
prefixUrl: _this.prefixUrl,
viewer: _this,
navigatorRotate: _this.navigatorRotate
});
}
_this.navigator.open(source, options);
}
//Instantiate a referencestrip if configured

View File

@ -9,7 +9,7 @@
this.viewer = OpenSeadragon( {
debugMode: true,
zoomPerScroll: 1.02,
// showNavigator: true,
showNavigator: true,
id: "contentDiv",
prefixUrl: "../../../build/openseadragon/images/"
} );
@ -87,6 +87,15 @@
y: 0,
width: 1
});
},
// ----------
bigTest: function() {
this.viewer.open("../../data/testpattern.dzi", {
x: -2,
y: -2,
width: 6
});
}
};