mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-21 20:56:09 +03:00
Merge pull request #252 from Sharpbarb/master
Add the ability to create a viewer and start at a specified page
This commit is contained in:
commit
e89562c03a
@ -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,
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user