From 29384cd5ff784b5d452672165efad70080ff6357 Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 23 Nov 2022 15:28:40 -0500 Subject: [PATCH 1/4] Added event for viewer destroy --- .DS_Store | Bin 0 -> 6148 bytes src/viewer.js | 14 +++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..375e40c5f8d1ace69802c263d6aff31c98d45125 GIT binary patch literal 6148 zcmeHKyJ`b55S)!2Fr;yrQooQt5XSj}{6Mg;2^<(=++UUN%BN-a(Hw`tDbmEVuo`K# zBcUm7ZvoiuGQ0p=02{g^zI<4k@4GMTp(2hJXAHynI37-?k;~i6xsN#Df)9+C@mDzG z6USd4dE3Rxk^)jd3P=GdaHk4Xk={Jr>HGC;DIf)|E8yRUMtAImQ(}BNI7ACTTr(WT zdGr#*<^f_aoDvzKSyG8fwQ4ae>5R9^>xENd(qVBk ZOIuwiB8E=se>xmkrfE1W3 zu*&7u>;EhLO8-A6X(a`uz`s(!*88{pj!&xEx_F$|+D3n;d(JoAjq{*zh;mGfa?FL7 e Date: Wed, 23 Nov 2022 15:33:09 -0500 Subject: [PATCH 2/4] banish .DS_Store --- .DS_Store | Bin 6148 -> 0 bytes .gitignore | 1 + 2 files changed, 1 insertion(+) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 375e40c5f8d1ace69802c263d6aff31c98d45125..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKyJ`b55S)!2Fr;yrQooQt5XSj}{6Mg;2^<(=++UUN%BN-a(Hw`tDbmEVuo`K# zBcUm7ZvoiuGQ0p=02{g^zI<4k@4GMTp(2hJXAHynI37-?k;~i6xsN#Df)9+C@mDzG z6USd4dE3Rxk^)jd3P=GdaHk4Xk={Jr>HGC;DIf)|E8yRUMtAImQ(}BNI7ACTTr(WT zdGr#*<^f_aoDvzKSyG8fwQ4ae>5R9^>xENd(qVBk ZOIuwiB8E=se>xmkrfE1W3 zu*&7u>;EhLO8-A6X(a`uz`s(!*88{pj!&xEx_F$|+D3n;d(JoAjq{*zh;mGfa?FL7 e Date: Sat, 26 Nov 2022 12:04:05 -0500 Subject: [PATCH 3/4] viewport _applyBoundaryConstraints fix --- src/viewport.js | 57 +++++++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 35 deletions(-) diff --git a/src/viewport.js b/src/viewport.js index da229885..0aff620d 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -529,26 +529,19 @@ $.Viewport.prototype = { var horizontalThreshold, leftDx, rightDx; if (newBounds.width > this._contentBoundsNoRotate.width) { horizontalThreshold = this.visibilityRatio * this._contentBoundsNoRotate.width; - leftDx = this._contentBoundsNoRotate.x - newBounds.x + horizontalThreshold; - rightDx = contentRight - boundsRight - horizontalThreshold; - - if (rightDx > 0) { - newBounds.x += rightDx; - } else if (leftDx < 0) { - newBounds.x += leftDx; - } } else { horizontalThreshold = this.visibilityRatio * newBounds.width; - leftDx = this._contentBoundsNoRotate.x - boundsRight + horizontalThreshold; - rightDx = contentRight - newBounds.x - horizontalThreshold; - if (horizontalThreshold > this._contentBoundsNoRotate.width) { - newBounds.x += (leftDx + rightDx) / 2; - } else if (rightDx < 0) { - newBounds.x += rightDx; - } else if (leftDx > 0) { - newBounds.x += leftDx; - } } + leftDx = this._contentBoundsNoRotate.x - boundsRight + horizontalThreshold; + rightDx = contentRight - newBounds.x - horizontalThreshold; + if (horizontalThreshold > this._contentBoundsNoRotate.width) { + newBounds.x += (leftDx + rightDx) / 2; + } else if (rightDx < 0) { + newBounds.x += rightDx; + } else if (leftDx > 0) { + newBounds.x += leftDx; + } + } if (this.wrapVertical) { @@ -560,26 +553,20 @@ $.Viewport.prototype = { var verticalThreshold, topDy, bottomDy; if (newBounds.height > this._contentBoundsNoRotate.height) { verticalThreshold = this.visibilityRatio * this._contentBoundsNoRotate.height; - topDy = this._contentBoundsNoRotate.y - newBounds.y + verticalThreshold; - bottomDy = contentBottom - boundsBottom - verticalThreshold; - - if (bottomDy > 0) { - newBounds.y += bottomDy; - } else if (topDy < 0) { - newBounds.y += topDy; - } - } else { + } else{ verticalThreshold = this.visibilityRatio * newBounds.height; - topDy = this._contentBoundsNoRotate.y - boundsBottom + verticalThreshold; - bottomDy = contentBottom - newBounds.y - verticalThreshold; - if (verticalThreshold > this._contentBoundsNoRotate.height) { - newBounds.y += (topDy + bottomDy) / 2; - } else if (bottomDy < 0) { - newBounds.y += bottomDy; - } else if (topDy > 0) { - newBounds.y += topDy; - } } + + topDy = this._contentBoundsNoRotate.y - boundsBottom + verticalThreshold; + bottomDy = contentBottom - newBounds.y - verticalThreshold; + if (verticalThreshold > this._contentBoundsNoRotate.height) { + newBounds.y += (topDy + bottomDy) / 2; + } else if (bottomDy < 0) { + newBounds.y += bottomDy; + } else if (topDy > 0) { + newBounds.y += topDy; + } + } return newBounds; From 968cb96bc428c2ff0f903a609e0ab6cbe5d0f5cc Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 28 Nov 2022 17:54:23 -0500 Subject: [PATCH 4/4] added before-destroy event; reverted viewport boundary constraint changes --- src/viewer.js | 13 +++++++++++ src/viewport.js | 59 ++++++++++++++++++++++++++++++------------------- 2 files changed, 49 insertions(+), 23 deletions(-) diff --git a/src/viewer.js b/src/viewer.js index a564814b..748137fe 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -756,6 +756,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, * viewer = null; //important * * @function + * @fires OpenSeadragon.Viewer.event:before-destroy * @fires OpenSeadragon.Viewer.event:destroy */ destroy: function( ) { @@ -764,6 +765,17 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, return; } + /** + * Raised when the viewer is about to be destroyed (see {@link OpenSeadragon.Viewer#before-destroy}). + * + * @event before-destroy + * @memberof OpenSeadragon.Viewer + * @type {object} + * @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event. + * @property {?Object} userData - Arbitrary subscriber-defined object. + */ + this.raiseEvent( 'before-destroy' ); + this._removeUpdatePixelDensityRatioEvent(); this.close(); @@ -841,6 +853,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, // clear our reference to the main element - they will need to pass it in again, creating a new viewer this.element = null; + /** * Raised when the viewer is destroyed (see {@link OpenSeadragon.Viewer#destroy}). * diff --git a/src/viewport.js b/src/viewport.js index 0aff620d..22d8b744 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -513,7 +513,7 @@ $.Viewport.prototype = { * @param {OpenSeadragon.Rect} bounds * @returns {OpenSeadragon.Rect} constrained bounds. */ - _applyBoundaryConstraints: function(bounds) { + _applyBoundaryConstraints: function(bounds) { var newBounds = new $.Rect( bounds.x, bounds.y, @@ -529,19 +529,26 @@ $.Viewport.prototype = { var horizontalThreshold, leftDx, rightDx; if (newBounds.width > this._contentBoundsNoRotate.width) { horizontalThreshold = this.visibilityRatio * this._contentBoundsNoRotate.width; + leftDx = this._contentBoundsNoRotate.x - newBounds.x + horizontalThreshold; + rightDx = contentRight - boundsRight - horizontalThreshold; + + if (rightDx > 0) { + newBounds.x += rightDx; + } else if (leftDx < 0) { + newBounds.x += leftDx; + } } else { horizontalThreshold = this.visibilityRatio * newBounds.width; + leftDx = this._contentBoundsNoRotate.x - boundsRight + horizontalThreshold; + rightDx = contentRight - newBounds.x - horizontalThreshold; + if (horizontalThreshold > this._contentBoundsNoRotate.width) { + newBounds.x += (leftDx + rightDx) / 2; + } else if (rightDx < 0) { + newBounds.x += rightDx; + } else if (leftDx > 0) { + newBounds.x += leftDx; + } } - leftDx = this._contentBoundsNoRotate.x - boundsRight + horizontalThreshold; - rightDx = contentRight - newBounds.x - horizontalThreshold; - if (horizontalThreshold > this._contentBoundsNoRotate.width) { - newBounds.x += (leftDx + rightDx) / 2; - } else if (rightDx < 0) { - newBounds.x += rightDx; - } else if (leftDx > 0) { - newBounds.x += leftDx; - } - } if (this.wrapVertical) { @@ -553,20 +560,26 @@ $.Viewport.prototype = { var verticalThreshold, topDy, bottomDy; if (newBounds.height > this._contentBoundsNoRotate.height) { verticalThreshold = this.visibilityRatio * this._contentBoundsNoRotate.height; - } else{ + topDy = this._contentBoundsNoRotate.y - newBounds.y + verticalThreshold; + bottomDy = contentBottom - boundsBottom - verticalThreshold; + + if (bottomDy > 0) { + newBounds.y += bottomDy; + } else if (topDy < 0) { + newBounds.y += topDy; + } + } else { verticalThreshold = this.visibilityRatio * newBounds.height; + topDy = this._contentBoundsNoRotate.y - boundsBottom + verticalThreshold; + bottomDy = contentBottom - newBounds.y - verticalThreshold; + if (verticalThreshold > this._contentBoundsNoRotate.height) { + newBounds.y += (topDy + bottomDy) / 2; + } else if (bottomDy < 0) { + newBounds.y += bottomDy; + } else if (topDy > 0) { + newBounds.y += topDy; + } } - - topDy = this._contentBoundsNoRotate.y - boundsBottom + verticalThreshold; - bottomDy = contentBottom - newBounds.y - verticalThreshold; - if (verticalThreshold > this._contentBoundsNoRotate.height) { - newBounds.y += (topDy + bottomDy) / 2; - } else if (bottomDy < 0) { - newBounds.y += bottomDy; - } else if (topDy > 0) { - newBounds.y += topDy; - } - } return newBounds;