Compare commits

..

6 Commits

Author SHA1 Message Date
Ian Gilman
c20b2bbab9 Changelog for #2160 2022-06-09 15:44:03 -07:00
Ian Gilman
71a1f06e35
Merge pull request #2160 from joedf/patch-2
apply only zoom constraint by default for scroll events
2022-06-09 15:41:17 -07:00
Joe DF
5b7be6be05 implement fixes from iangilman 2022-05-19 16:52:56 -04:00
Joe DF
325f65fe5c attempt no.2 to fix #2160 2022-05-18 11:16:28 -04:00
Joe DF
7d6437b2cd Revert "apply only zoom constraint by default for scroll events"
This reverts commit a6d1472134.
2022-05-18 10:48:58 -04:00
Joe DF
a6d1472134 apply only zoom constraint by default for scroll events 2022-05-12 15:31:51 -04:00
2 changed files with 46 additions and 18 deletions

View File

@ -3,6 +3,8 @@ OPENSEADRAGON CHANGELOG
3.2.0: (in progress) 3.2.0: (in progress)
* Improved the constraints that keep the image in the viewer, specifically when zoomed out a lot (#2160 @joedf)
3.1.0: 3.1.0:
* Added subPixelRoundingForTransparency Viewer option to address seams that can appear in semi-transparent images (#2075 @TanukiSharp) * Added subPixelRoundingForTransparency Viewer option to address seams that can appear in semi-transparent images (#2075 @TanukiSharp)

View File

@ -500,12 +500,24 @@ $.Viewport.prototype = {
if (this.wrapHorizontal) { if (this.wrapHorizontal) {
//do nothing //do nothing
} else { } else {
var horizontalThreshold = this.visibilityRatio * newBounds.width;
var boundsRight = newBounds.x + newBounds.width; var boundsRight = newBounds.x + newBounds.width;
var contentRight = this._contentBoundsNoRotate.x + this._contentBoundsNoRotate.width; var contentRight = this._contentBoundsNoRotate.x + this._contentBoundsNoRotate.width;
var leftDx = this._contentBoundsNoRotate.x - boundsRight + horizontalThreshold;
var rightDx = contentRight - newBounds.x - horizontalThreshold;
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) { if (horizontalThreshold > this._contentBoundsNoRotate.width) {
newBounds.x += (leftDx + rightDx) / 2; newBounds.x += (leftDx + rightDx) / 2;
} else if (rightDx < 0) { } else if (rightDx < 0) {
@ -514,16 +526,29 @@ $.Viewport.prototype = {
newBounds.x += leftDx; newBounds.x += leftDx;
} }
} }
}
if (this.wrapVertical) { if (this.wrapVertical) {
//do nothing //do nothing
} else { } else {
var verticalThreshold = this.visibilityRatio * newBounds.height;
var boundsBottom = newBounds.y + newBounds.height; var boundsBottom = newBounds.y + newBounds.height;
var contentBottom = this._contentBoundsNoRotate.y + this._contentBoundsNoRotate.height; var contentBottom = this._contentBoundsNoRotate.y + this._contentBoundsNoRotate.height;
var topDy = this._contentBoundsNoRotate.y - boundsBottom + verticalThreshold;
var bottomDy = contentBottom - newBounds.y - verticalThreshold;
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 {
verticalThreshold = this.visibilityRatio * newBounds.height;
topDy = this._contentBoundsNoRotate.y - boundsBottom + verticalThreshold;
bottomDy = contentBottom - newBounds.y - verticalThreshold;
if (verticalThreshold > this._contentBoundsNoRotate.height) { if (verticalThreshold > this._contentBoundsNoRotate.height) {
newBounds.y += (topDy + bottomDy) / 2; newBounds.y += (topDy + bottomDy) / 2;
} else if (bottomDy < 0) { } else if (bottomDy < 0) {
@ -532,6 +557,7 @@ $.Viewport.prototype = {
newBounds.y += topDy; newBounds.y += topDy;
} }
} }
}
return newBounds; return newBounds;
}, },