From bb6875569902cd0e51f4397e7900d311ad58cfc8 Mon Sep 17 00:00:00 2001 From: Robert Saric Date: Sun, 14 May 2017 15:56:21 +0200 Subject: [PATCH] fix for #1191 (extension of Viewer.open() function with initialPage argument) --- src/viewer.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/viewer.js b/src/viewer.js index ec4c8242..1ac95a0e 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -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) {