mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
Merge pull request #255 from avandecreme/master
Check hash in viewer constructor.
This commit is contained in:
commit
6655523db4
@ -1160,6 +1160,7 @@ function drawTiles( drawer, lastDrawn ){
|
|||||||
//$.console.log("Rendering collection tile %s | %s | %s", tile.y, tile.y, position);
|
//$.console.log("Rendering collection tile %s | %s | %s", tile.y, tile.y, position);
|
||||||
if( tileSource ){
|
if( tileSource ){
|
||||||
drawer.collectionOverlays[ tileKey ] = viewer = new $.Viewer({
|
drawer.collectionOverlays[ tileKey ] = viewer = new $.Viewer({
|
||||||
|
hash: viewport.viewer.hash + "-" + tileKey,
|
||||||
element: $.makeNeutralElement( "div" ),
|
element: $.makeNeutralElement( "div" ),
|
||||||
mouseNavEnabled: false,
|
mouseNavEnabled: false,
|
||||||
showNavigator: false,
|
showNavigator: false,
|
||||||
|
@ -100,7 +100,7 @@ $.Viewer = function( options ) {
|
|||||||
|
|
||||||
//internal state and dom identifiers
|
//internal state and dom identifiers
|
||||||
id: options.id,
|
id: options.id,
|
||||||
hash: options.id,
|
hash: options.hash || options.id,
|
||||||
|
|
||||||
//dom nodes
|
//dom nodes
|
||||||
element: null,
|
element: null,
|
||||||
@ -147,6 +147,15 @@ $.Viewer = function( options ) {
|
|||||||
|
|
||||||
}, $.DEFAULT_SETTINGS, options );
|
}, $.DEFAULT_SETTINGS, options );
|
||||||
|
|
||||||
|
if ( typeof( this.hash) === "undefined" ) {
|
||||||
|
throw new Error("A hash must be defined, either by specifying options.id or options.hash.");
|
||||||
|
}
|
||||||
|
if ( typeof( THIS[ this.hash ] ) !== "undefined" ) {
|
||||||
|
// We don't want to throw an error here, as the user might have discarded
|
||||||
|
// the previous viewer with the same hash and now want to recreate it.
|
||||||
|
$.console.warn("Hash " + this.hash + " has already been used.");
|
||||||
|
}
|
||||||
|
|
||||||
//Private state properties
|
//Private state properties
|
||||||
THIS[ this.hash ] = {
|
THIS[ this.hash ] = {
|
||||||
"fsBoundsDelta": new $.Point( 1, 1 ),
|
"fsBoundsDelta": new $.Point( 1, 1 ),
|
||||||
|
Loading…
Reference in New Issue
Block a user