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

@ -216,15 +216,19 @@ $.Navigator = function( options ){
unneededElement.parentNode.removeChild(unneededElement); unneededElement.parentNode.removeChild(unneededElement);
} }
if (options.navigatorRotate) if (options.navigatorRotate) {
{
options.viewer.addHandler("rotate", function (args) { options.viewer.addHandler("rotate", function (args) {
_setTransformRotate(_this.displayRegionContainer, args.degrees); _setTransformRotate(_this.displayRegionContainer, args.degrees);
_setTransformRotate(_this.displayRegion, -args.degrees); _setTransformRotate(_this.displayRegion, -args.degrees);
_this.viewport.setRotation(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 */{ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /** @lends OpenSeadragon.Navigator.prototype */{
@ -313,7 +317,7 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
}, },
open: function( source ) { open: function(source, options) {
this.updateSize(); this.updateSize();
var containerSize = this.viewer.viewport.containerSize.times( this.sizeRatio ); var containerSize = this.viewer.viewport.containerSize.times( this.sizeRatio );
var ts = source.getTileSize(source.maxLevel); var ts = source.getTileSize(source.maxLevel);
@ -322,7 +326,7 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
} else { } else {
this.minPixelRatio = this.viewer.minPixelRatio; 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, { _this.world.addItem( tiledImage, {
index: options.index index: options.index
}); });
if (_this.navigator) {
var optionsClone = $.extend({}, options, {
tileSource: tileSource
});
_this.navigator.addTiledImage(optionsClone);
}
}, function( event ) { }, function( event ) {
event.options = options; event.options = options;
raiseAddItemFailed(event); raiseAddItemFailed(event);
@ -1956,9 +1964,7 @@ function openTileSource( viewer, source, options ) {
if ( _this.showNavigator && !_this.collectionMode ){ if ( _this.showNavigator && !_this.collectionMode ){
// Note: By passing the fully parsed source, the navigator doesn't // Note: By passing the fully parsed source, the navigator doesn't
// have to load it again. // have to load it again.
if ( _this.navigator ) { if (!_this.navigator) {
_this.navigator.open( source );
} else {
_this.navigator = new $.Navigator({ _this.navigator = new $.Navigator({
id: _this.navigatorId, id: _this.navigatorId,
position: _this.navigatorPosition, position: _this.navigatorPosition,
@ -1969,13 +1975,14 @@ function openTileSource( viewer, source, options ) {
width: _this.navigatorWidth, width: _this.navigatorWidth,
height: _this.navigatorHeight, height: _this.navigatorHeight,
autoResize: _this.navigatorAutoResize, autoResize: _this.navigatorAutoResize,
tileSources: source,
tileHost: _this.tileHost, tileHost: _this.tileHost,
prefixUrl: _this.prefixUrl, prefixUrl: _this.prefixUrl,
viewer: _this, viewer: _this,
navigatorRotate: _this.navigatorRotate navigatorRotate: _this.navigatorRotate
}); });
} }
_this.navigator.open(source, options);
} }
//Instantiate a referencestrip if configured //Instantiate a referencestrip if configured

View File

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