From 6d35f6df2c4af1a3a727ff7d4655e85a71d340f9 Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 28 Nov 2022 17:45:21 -0500 Subject: [PATCH 1/3] boundary constraint logic fix --- src/viewport.js | 59 +++++++++++++++++++------------------------------ 1 file changed, 23 insertions(+), 36 deletions(-) diff --git a/src/viewport.js b/src/viewport.js index ae951eba..bf6ece60 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -514,7 +514,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, @@ -530,26 +530,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) { @@ -561,26 +554,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 5aa5d7ad56bf971487f1d7ad4331b0398e062295 Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 29 Nov 2022 17:43:14 -0500 Subject: [PATCH 2/3] removed extra space --- src/viewport.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/viewport.js b/src/viewport.js index bf6ece60..2df47df9 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -514,7 +514,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, From bd8e8a9e7f84cb11a7a3055f691d9f7b7b0cef44 Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 30 Nov 2022 16:48:04 -0500 Subject: [PATCH 3/3] add line spacing --- src/viewport.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/viewport.js b/src/viewport.js index 2df47df9..8d511602 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -533,6 +533,7 @@ $.Viewport.prototype = { } else { horizontalThreshold = this.visibilityRatio * newBounds.width; } + leftDx = this._contentBoundsNoRotate.x - boundsRight + horizontalThreshold; rightDx = contentRight - newBounds.x - horizontalThreshold; if (horizontalThreshold > this._contentBoundsNoRotate.width) {