ReferenceStrip fixes

This commit is contained in:
Ian Gilman 2014-11-17 14:03:14 -08:00
parent 4bd4dd5618
commit 0e31b67ca5
3 changed files with 42 additions and 34 deletions

View File

@ -289,6 +289,13 @@ $.extend( $.ReferenceStrip.prototype, $.EventSource.prototype, $.Viewer.prototyp
return true;
}
return false;
},
// Overrides Viewer.destroy
destroy: function() {
if (this.element) {
this.element.parentNode.removeChild(this.element);
}
}
} );

View File

@ -487,40 +487,15 @@ $.Viewer = function( options ) {
});
}
//Instantiate a referencestrip if configured
if ( this.showReferenceStrip ){
this.referenceStrip = new $.ReferenceStrip({
id: this.referenceStripElement,
position: this.referenceStripPosition,
sizeRatio: this.referenceStripSizeRatio,
scroll: this.referenceStripScroll,
height: this.referenceStripHeight,
width: this.referenceStripWidth,
tileSources: this.tileSources,
tileHost: this.tileHost,
prefixUrl: this.prefixUrl,
viewer: this
});
}
// Sequence mode
if (this.sequenceMode) {
if (this.tileSources && this.tileSources.length) {
this._sequenceIndex = Math.max(0, Math.min(this.tileSources.length - 1, this.initialPage));
}
this.bindSequenceControls();
}
// Open initial tilesources
if ( this.tileSources && this.tileSources.length) {
if (this.sequenceMode) {
this.open(this.tileSources[this._sequenceIndex]);
this._updateSequenceButtons( this._sequenceIndex );
} else {
this.open( this.tileSources );
}
}
// Add custom controls
for ( i = 0; i < this.customControls.length; i++ ) {
@ -582,10 +557,30 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
}
if (this.sequenceMode && $.isArray(tileSources)) {
if (this.referenceStrip) {
this.referenceStrip.destroy();
this.referenceStrip = null;
}
this.tileSources = tileSources;
this._sequenceIndex = 0;
if (tileSources.length) {
this.open(tileSources[0]);
this._sequenceIndex = Math.max(0, Math.min(this.tileSources.length - 1, this.initialPage));
if (this.tileSources.length) {
this.open(this.tileSources[this._sequenceIndex]);
if ( this.showReferenceStrip ){
this.referenceStrip = new $.ReferenceStrip({
id: this.referenceStripElement,
position: this.referenceStripPosition,
sizeRatio: this.referenceStripSizeRatio,
scroll: this.referenceStripScroll,
height: this.referenceStripHeight,
width: this.referenceStripWidth,
tileSources: this.tileSources,
tileHost: this.tileHost,
prefixUrl: this.prefixUrl,
viewer: this
});
}
}
this._updateSequenceButtons( this._sequenceIndex );
@ -772,6 +767,11 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
//this.unbindSequenceControls()
//this.unbindStandardControls()
if (this.referenceStrip) {
this.referenceStrip.destroy();
this.referenceStrip = null;
}
if ( this._updateRequestId !== null ) {
$.cancelAnimationFrame( this._updateRequestId );
this._updateRequestId = null;

View File

@ -6,7 +6,7 @@
init: function() {
var self = this;
var testInitialOpen = true;
var testInitialOpen = false;
var testOverlays = false;
var testMargins = false;
var testNavigator = false;
@ -106,8 +106,9 @@
});
}
// this.crossTest2();
// this.collectionTest();
if (!testInitialOpen) {
this.collectionTest();
}
},
// ----------