From a783edc76f797a684ec894f580e5f940207007ca Mon Sep 17 00:00:00 2001 From: Robert Saric Date: Tue, 6 Jun 2017 18:21:14 +0200 Subject: [PATCH 1/3] fix for #1210 (Dinamically show ReferenceStrip) --- src/viewer.js | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/viewer.js b/src/viewer.js index 1fb5027e..5f693d1f 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -2132,6 +2132,58 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, */ _cancelPendingImages: function() { this._loadQueue = []; + }, + + /** + * Remove the reference strip. + * @function + * @return {OpenSeadragon.Viewer} Chainable. + */ + removeReferenceStrip: function() { + this.showReferenceStrip = false; + + if (this.sequenceMode) { + if (this.referenceStrip) { + this.referenceStrip.destroy(); + this.referenceStrip = null; + } + } + + return this; + }, + + /** + * Display the reference strip based on the currently set tileSources. + * @function + * @return {OpenSeadragon.Viewer} Chainable. + */ + addReferenceStrip: function() { + this.showReferenceStrip = true; + + if (this.sequenceMode) { + if (this.referenceStrip) { + this.referenceStrip.destroy(); + this.referenceStrip = null; + } + + if (this.tileSources.length && this.tileSources.length > 1) { + 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, + prefixUrl: this.prefixUrl, + viewer: this + }); + + this.referenceStrip.setFocus( this._sequenceIndex ); + } + } + + return this; } }); From ec7e5e541902e86d8218668f826f40bd489f1e2f Mon Sep 17 00:00:00 2001 From: Robert Saric Date: Sat, 24 Jun 2017 17:58:19 +0200 Subject: [PATCH 2/3] fix for #1210 (Dinamically show ReferenceStrip) additional changes --- src/viewer.js | 40 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/src/viewer.js b/src/viewer.js index 5f693d1f..e6a630ee 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -504,10 +504,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, } if (this.sequenceMode && $.isArray(tileSources)) { - if (this.referenceStrip) { - this.referenceStrip.destroy(); - this.referenceStrip = null; - } + this.removeReferenceStrip(); if (typeof initialPage != 'undefined' && !isNaN(initialPage)) { this.initialPage = initialPage; @@ -519,19 +516,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, 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, - prefixUrl: this.prefixUrl, - viewer: this - }); - - this.referenceStrip.setFocus( this._sequenceIndex ); + this.addReferenceStrip(); } } @@ -2136,20 +2121,18 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, /** * Remove the reference strip. + * @param {Boolean} hide - Disables automatic showing of the reference strip in the future until manually re-enabled. * @function - * @return {OpenSeadragon.Viewer} Chainable. */ - removeReferenceStrip: function() { - this.showReferenceStrip = false; - - if (this.sequenceMode) { - if (this.referenceStrip) { - this.referenceStrip.destroy(); - this.referenceStrip = null; - } + removeReferenceStrip: function(hide) { + if (hide) { + this.showReferenceStrip = false; } - return this; + if (this.referenceStrip) { + this.referenceStrip.destroy(); + this.referenceStrip = null; + } }, /** @@ -2162,8 +2145,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, if (this.sequenceMode) { if (this.referenceStrip) { - this.referenceStrip.destroy(); - this.referenceStrip = null; + return this; } if (this.tileSources.length && this.tileSources.length > 1) { From 51cf6201cf1a8fe3db343e0dbe5c19683ede219a Mon Sep 17 00:00:00 2001 From: Robert Saric Date: Sat, 1 Jul 2017 09:57:36 +0200 Subject: [PATCH 3/3] fix for #1210 (Dinamically show ReferenceStrip) yet additional changes --- src/viewer.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/viewer.js b/src/viewer.js index e6a630ee..5a3cfa8f 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -504,7 +504,10 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, } if (this.sequenceMode && $.isArray(tileSources)) { - this.removeReferenceStrip(); + if (this.referenceStrip) { + this.referenceStrip.destroy(); + this.referenceStrip = null; + } if (typeof initialPage != 'undefined' && !isNaN(initialPage)) { this.initialPage = initialPage; @@ -2120,14 +2123,11 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, }, /** - * Remove the reference strip. - * @param {Boolean} hide - Disables automatic showing of the reference strip in the future until manually re-enabled. + * Removes the reference strip and disables displaying it. * @function */ - removeReferenceStrip: function(hide) { - if (hide) { - this.showReferenceStrip = false; - } + removeReferenceStrip: function() { + this.showReferenceStrip = false; if (this.referenceStrip) { this.referenceStrip.destroy(); @@ -2136,16 +2136,15 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, }, /** - * Display the reference strip based on the currently set tileSources. + * Enables and displays the reference strip based on the currently set tileSources. * @function - * @return {OpenSeadragon.Viewer} Chainable. */ addReferenceStrip: function() { this.showReferenceStrip = true; if (this.sequenceMode) { if (this.referenceStrip) { - return this; + return; } if (this.tileSources.length && this.tileSources.length > 1) { @@ -2163,9 +2162,9 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, this.referenceStrip.setFocus( this._sequenceIndex ); } + } else { + $.console.warn('Attempting to display a reference strip while "sequenceMode" is off.'); } - - return this; } });