mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-29 08:36:10 +03:00
Code that fixes #890, new test passes. Events.js test needed fixing with good value, unrelated to actual test.
This commit is contained in:
parent
0035b3f36f
commit
c91039b545
@ -503,45 +503,56 @@ $.Viewport.prototype = {
|
|||||||
} else {
|
} else {
|
||||||
var dx = 0;
|
var dx = 0;
|
||||||
var thresholdLeft = newBounds.x + (newBounds.width - horizontalThreshold);
|
var thresholdLeft = newBounds.x + (newBounds.width - horizontalThreshold);
|
||||||
if (this._contentBoundsNoRotate.x > thresholdLeft) {
|
var leftDx = this._contentBoundsNoRotate.x - thresholdLeft;
|
||||||
dx = this._contentBoundsNoRotate.x - thresholdLeft;
|
|
||||||
}
|
|
||||||
|
|
||||||
var contentRight = this._contentBoundsNoRotate.x + this._contentBoundsNoRotate.width;
|
var contentRight = this._contentBoundsNoRotate.x + this._contentBoundsNoRotate.width;
|
||||||
var thresholdRight = newBounds.x + horizontalThreshold;
|
var thresholdRight = newBounds.x + horizontalThreshold;
|
||||||
|
var rightDx = contentRight - thresholdRight;
|
||||||
|
|
||||||
|
if (this._contentBoundsNoRotate.x > thresholdLeft) {
|
||||||
|
dx = leftDx;
|
||||||
|
}
|
||||||
if (contentRight < thresholdRight) {
|
if (contentRight < thresholdRight) {
|
||||||
var newDx = contentRight - thresholdRight;
|
|
||||||
if (dx) {
|
if (dx) {
|
||||||
dx = (dx + newDx) / 2;
|
dx = (dx + rightDx) / 2;
|
||||||
} else {
|
} else {
|
||||||
dx = newDx;
|
dx = rightDx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (horizontalThreshold > this._contentBoundsNoRotate.width && (newBounds.x > -thresholdLeft || newBounds.x + horizontalThreshold < 1)) {
|
||||||
|
newBounds.x += (leftDx + rightDx) / 2;
|
||||||
|
} else {
|
||||||
newBounds.x += dx;
|
newBounds.x += dx;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this.wrapVertical) {
|
if (this.wrapVertical) {
|
||||||
//do nothing
|
//do nothing
|
||||||
} else {
|
} else {
|
||||||
var dy = 0;
|
var dy = 0;
|
||||||
var thresholdTop = newBounds.y + (newBounds.height - verticalThreshold);
|
var thresholdTop = newBounds.y + (newBounds.height - verticalThreshold);
|
||||||
if (this._contentBoundsNoRotate.y > thresholdTop) {
|
var topDy = this._contentBoundsNoRotate.y - thresholdTop;
|
||||||
dy = this._contentBoundsNoRotate.y - thresholdTop;
|
|
||||||
}
|
|
||||||
|
|
||||||
var contentBottom = this._contentBoundsNoRotate.y + this._contentBoundsNoRotate.height;
|
var contentBottom = this._contentBoundsNoRotate.y + this._contentBoundsNoRotate.height;
|
||||||
var thresholdBottom = newBounds.y + verticalThreshold;
|
var thresholdBottom = newBounds.y + verticalThreshold;
|
||||||
|
var bottomDy = contentBottom - thresholdBottom;
|
||||||
|
|
||||||
|
if (this._contentBoundsNoRotate.y > thresholdTop) {
|
||||||
|
dy = topDy;
|
||||||
|
}
|
||||||
if (contentBottom < thresholdBottom) {
|
if (contentBottom < thresholdBottom) {
|
||||||
var newDy = contentBottom - thresholdBottom;
|
|
||||||
if (dy) {
|
if (dy) {
|
||||||
dy = (dy + newDy) / 2;
|
dy = (dy + bottomDy) / 2;
|
||||||
} else {
|
} else {
|
||||||
dy = newDy;
|
dy = bottomDy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (verticalThreshold > this._contentBoundsNoRotate.height && (newBounds.y > -thresholdTop || newBounds.y + verticalThreshold < 1)) {
|
||||||
|
newBounds.y += (topDy + bottomDy) / 2;
|
||||||
|
} else {
|
||||||
newBounds.y += dy;
|
newBounds.y += dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (this.viewer) {
|
if (this.viewer) {
|
||||||
/**
|
/**
|
||||||
* Raised when the viewport constraints are applied (see {@link OpenSeadragon.Viewport#applyConstraints}).
|
* Raised when the viewport constraints are applied (see {@link OpenSeadragon.Viewport#applyConstraints}).
|
||||||
|
@ -820,8 +820,8 @@
|
|||||||
Util.assessNumericValue(zoom, 0.002, epsilon,
|
Util.assessNumericValue(zoom, 0.002, epsilon,
|
||||||
"Zoom should not be prevented");
|
"Zoom should not be prevented");
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
|
new OpenSeadragon.Rect(-249.5, -0.25, 500, 0.5),
|
||||||
bounds,
|
bounds,
|
||||||
new OpenSeadragon.Rect(-250, -0.25, 500, 0.5),
|
|
||||||
epsilon,
|
epsilon,
|
||||||
'Pan should not be prevented');
|
'Pan should not be prevented');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user