diff --git a/src/openseadragon.js b/src/openseadragon.js index 4e63fd22..0c0a01ca 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -489,7 +489,8 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ xmlPath: null, tileSources: null, tileHost: null, - + initialPage: 0, + //PAN AND ZOOM SETTINGS AND CONSTRAINTS panHorizontal: true, panVertical: true, diff --git a/src/viewer.js b/src/viewer.js index ecd8560f..7c3fd2d7 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -200,12 +200,19 @@ $.Viewer = function( options ) { if( this.tileSources.length > 1 ){ THIS[ this.hash ].sequenced = true; } - initialTileSource = this.tileSources[ 0 ]; + + //Keeps the initial page within bounds + if ( this.initialPage > this.tileSources.length - 1 ){ + this.initialPage = this.tileSources.length - 1; + } + + initialTileSource = this.tileSources[ this.initialPage ]; + + //Update the sequence (aka currrent page) property + THIS[ this.hash ].sequence = this.initialPage; } else { initialTileSource = this.tileSources; } - - this.open( initialTileSource ); } this.element = this.element || document.getElementById( this.id ); @@ -343,6 +350,14 @@ $.Viewer = function( options ) { this.bindStandardControls(); this.bindSequenceControls(); + if ( initialTileSource ) { + this.open( initialTileSource ); + + if ( this.tileSources.length > 1 ) { + this._updateSequenceButtons( this.initialPage ); + } + } + for ( i = 0; i < this.customControls.length; i++ ) { this.addControl( this.customControls[ i ].id, @@ -1066,7 +1081,16 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, } return this; }, - + + /** + * Gets the active page of a sequence + * @function + * @name OpenSeadragon.Viewer.prototype.currentPage + * @return {Number} + */ + currentPage: function () { + return THIS[ this.hash ].sequence; + }, /** * @function @@ -1082,6 +1106,31 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, THIS[ this.hash ].sequence = page; + this._updateSequenceButtons( page ); + + this.open( this.tileSources[ page ] ); + } + + if( $.isFunction( this.onPageChange ) ){ + this.onPageChange({ + page: page, + viewer: this + }); + } + if( this.referenceStrip ){ + this.referenceStrip.setFocus( page ); + } + return this; + }, + + /** + * Updates the sequence buttons. + * @function + * @private + * @param {Number} Sequence Value + */ + _updateSequenceButtons: function (page) { + if( this.nextButton ){ if( ( this.tileSources.length - 1 ) === page ){ //Disable next button @@ -1102,22 +1151,8 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, } } } - - this.open( this.tileSources[ page ] ); - } - - if( $.isFunction( this.onPageChange ) ){ - this.onPageChange({ - page: page, - viewer: this - }); - } - if( this.referenceStrip ){ - this.referenceStrip.setFocus( page ); - } - return this; - }, - + }, + /** * Display a message in the viewport * @function