diff --git a/src/referencestrip.js b/src/referencestrip.js index f68744b2..0c0fdf61 100644 --- a/src/referencestrip.js +++ b/src/referencestrip.js @@ -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); + } } } ); @@ -467,7 +474,7 @@ function loadPanels( strip, viewerSize, scroll ) { */ function onStripEnter( event ) { var element = event.eventSource.element; - + //$.setElementOpacity(element, 0.8); //element.style.border = '1px solid #555'; @@ -495,7 +502,7 @@ function onStripEnter( event ) { */ function onStripExit( event ) { var element = event.eventSource.element; - + if ( 'horizontal' == this.scroll ) { //element.style.paddingTop = "10px"; diff --git a/src/viewer.js b/src/viewer.js index 32c7acb5..e5269a8b 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -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 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 ); - } + this.open( this.tileSources ); } // Add custom controls @@ -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; diff --git a/test/demo/collections/main.js b/test/demo/collections/main.js index fe4efe1a..d1f9c652 100644 --- a/test/demo/collections/main.js +++ b/test/demo/collections/main.js @@ -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(); + } }, // ----------