mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-02-16 14:53:14 +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,
|
xmlPath: null,
|
||||||
tileSources: null,
|
tileSources: null,
|
||||||
tileHost: null,
|
tileHost: null,
|
||||||
|
initialPage: 0,
|
||||||
|
|
||||||
//PAN AND ZOOM SETTINGS AND CONSTRAINTS
|
//PAN AND ZOOM SETTINGS AND CONSTRAINTS
|
||||||
panHorizontal: true,
|
panHorizontal: true,
|
||||||
panVertical: true,
|
panVertical: true,
|
||||||
|
@ -200,12 +200,19 @@ $.Viewer = function( options ) {
|
|||||||
if( this.tileSources.length > 1 ){
|
if( this.tileSources.length > 1 ){
|
||||||
THIS[ this.hash ].sequenced = true;
|
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 {
|
} else {
|
||||||
initialTileSource = this.tileSources;
|
initialTileSource = this.tileSources;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.open( initialTileSource );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.element = this.element || document.getElementById( this.id );
|
this.element = this.element || document.getElementById( this.id );
|
||||||
@ -343,6 +350,14 @@ $.Viewer = function( options ) {
|
|||||||
this.bindStandardControls();
|
this.bindStandardControls();
|
||||||
this.bindSequenceControls();
|
this.bindSequenceControls();
|
||||||
|
|
||||||
|
if ( initialTileSource ) {
|
||||||
|
this.open( initialTileSource );
|
||||||
|
|
||||||
|
if ( this.tileSources.length > 1 ) {
|
||||||
|
this._updateSequenceButtons( this.initialPage );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for ( i = 0; i < this.customControls.length; i++ ) {
|
for ( i = 0; i < this.customControls.length; i++ ) {
|
||||||
this.addControl(
|
this.addControl(
|
||||||
this.customControls[ i ].id,
|
this.customControls[ i ].id,
|
||||||
@ -1066,7 +1081,16 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
}
|
}
|
||||||
return this;
|
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
|
* @function
|
||||||
@ -1082,6 +1106,31 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
|
|
||||||
THIS[ this.hash ].sequence = page;
|
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.nextButton ){
|
||||||
if( ( this.tileSources.length - 1 ) === page ){
|
if( ( this.tileSources.length - 1 ) === page ){
|
||||||
//Disable next button
|
//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
|
* Display a message in the viewport
|
||||||
* @function
|
* @function
|
||||||
|
Loading…
x
Reference in New Issue
Block a user