mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 05:06:09 +03:00
Merge pull request #2160 from joedf/patch-2
apply only zoom constraint by default for scroll events
This commit is contained in:
commit
71a1f06e35
@ -500,36 +500,62 @@ $.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;
|
|
||||||
|
|
||||||
if (horizontalThreshold > this._contentBoundsNoRotate.width) {
|
var horizontalThreshold, leftDx, rightDx;
|
||||||
newBounds.x += (leftDx + rightDx) / 2;
|
if (newBounds.width > this._contentBoundsNoRotate.width) {
|
||||||
} else if (rightDx < 0) {
|
horizontalThreshold = this.visibilityRatio * this._contentBoundsNoRotate.width;
|
||||||
newBounds.x += rightDx;
|
leftDx = this._contentBoundsNoRotate.x - newBounds.x + horizontalThreshold;
|
||||||
} else if (leftDx > 0) {
|
rightDx = contentRight - boundsRight - horizontalThreshold;
|
||||||
newBounds.x += leftDx;
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
if (verticalThreshold > this._contentBoundsNoRotate.height) {
|
var verticalThreshold, topDy, bottomDy;
|
||||||
newBounds.y += (topDy + bottomDy) / 2;
|
if (newBounds.height > this._contentBoundsNoRotate.height) {
|
||||||
} else if (bottomDy < 0) {
|
verticalThreshold = this.visibilityRatio * this._contentBoundsNoRotate.height;
|
||||||
newBounds.y += bottomDy;
|
topDy = this._contentBoundsNoRotate.y - newBounds.y + verticalThreshold;
|
||||||
} else if (topDy > 0) {
|
bottomDy = contentBottom - boundsBottom - verticalThreshold;
|
||||||
newBounds.y += topDy;
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user