fix for #1191 (extension of Viewer.open() function with initialPage argument)

This commit is contained in:
Robert Saric 2017-05-14 15:56:21 +02:00
parent 85e60b759b
commit bb68755699

View File

@ -96,6 +96,12 @@ $.Viewer = function( options ) {
//internal state and dom identifiers
id: options.id,
hash: options.hash || nextHash++,
/**
* If sequenceMode is true, display this page initially for the given tileSources.
* @member {Number} initialPage
* @memberof OpenSeadragon.Viewer#
*/
initialPage: 0,
//dom nodes
/**
@ -481,11 +487,13 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
* except for the index property; images are added in sequence.
* A TileSource specifier is anything you could pass as the tileSource property
* of the options parameter for {@link OpenSeadragon.Viewer#addTiledImage}.
* @param {Number} initialPage - If sequenceMode is true, display this page initially
* for the given tileSources. If specified, will overwrite the existing homonymous option.
* @return {OpenSeadragon.Viewer} Chainable.
* @fires OpenSeadragon.Viewer.event:open
* @fires OpenSeadragon.Viewer.event:open-failed
*/
open: function (tileSources) {
open: function (tileSources, initialPage) {
var _this = this;
this.close();
@ -500,6 +508,10 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
this.referenceStrip = null;
}
if (typeof initialPage != 'undefined' && !isNaN(initialPage)) {
this.initialPage = initialPage;
}
this.tileSources = tileSources;
this._sequenceIndex = Math.max(0, Math.min(this.tileSources.length - 1, this.initialPage));
if (this.tileSources.length) {