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 true;
} }
return false; return false;
},
// Overrides Viewer.destroy
destroy: function() {
if (this.element) {
this.element.parentNode.removeChild(this.element);
}
} }
} ); } );
@ -467,7 +474,7 @@ function loadPanels( strip, viewerSize, scroll ) {
*/ */
function onStripEnter( event ) { function onStripEnter( event ) {
var element = event.eventSource.element; var element = event.eventSource.element;
//$.setElementOpacity(element, 0.8); //$.setElementOpacity(element, 0.8);
//element.style.border = '1px solid #555'; //element.style.border = '1px solid #555';
@ -495,7 +502,7 @@ function onStripEnter( event ) {
*/ */
function onStripExit( event ) { function onStripExit( event ) {
var element = event.eventSource.element; var element = event.eventSource.element;
if ( 'horizontal' == this.scroll ) { if ( 'horizontal' == this.scroll ) {
//element.style.paddingTop = "10px"; //element.style.paddingTop = "10px";

View File

@ -487,39 +487,14 @@ $.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 // Sequence mode
if (this.sequenceMode) { if (this.sequenceMode) {
if (this.tileSources && this.tileSources.length) {
this._sequenceIndex = Math.max(0, Math.min(this.tileSources.length - 1, this.initialPage));
}
this.bindSequenceControls(); this.bindSequenceControls();
} }
// Open initial tilesources // Open initial tilesources
if ( this.tileSources && this.tileSources.length) { if ( this.tileSources && this.tileSources.length) {
if (this.sequenceMode) { this.open( this.tileSources );
this.open(this.tileSources[this._sequenceIndex]);
this._updateSequenceButtons( this._sequenceIndex );
} else {
this.open( this.tileSources );
}
} }
// Add custom controls // Add custom controls
@ -582,10 +557,30 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
} }
if (this.sequenceMode && $.isArray(tileSources)) { if (this.sequenceMode && $.isArray(tileSources)) {
if (this.referenceStrip) {
this.referenceStrip.destroy();
this.referenceStrip = null;
}
this.tileSources = tileSources; this.tileSources = tileSources;
this._sequenceIndex = 0; this._sequenceIndex = Math.max(0, Math.min(this.tileSources.length - 1, this.initialPage));
if (tileSources.length) { if (this.tileSources.length) {
this.open(tileSources[0]); 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 ); this._updateSequenceButtons( this._sequenceIndex );
@ -772,6 +767,11 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
//this.unbindSequenceControls() //this.unbindSequenceControls()
//this.unbindStandardControls() //this.unbindStandardControls()
if (this.referenceStrip) {
this.referenceStrip.destroy();
this.referenceStrip = null;
}
if ( this._updateRequestId !== null ) { if ( this._updateRequestId !== null ) {
$.cancelAnimationFrame( this._updateRequestId ); $.cancelAnimationFrame( this._updateRequestId );
this._updateRequestId = null; this._updateRequestId = null;

View File

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