diff --git a/src/viewport.js b/src/viewport.js index 659cef60..02bf316f 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -577,10 +577,11 @@ $.Viewport.prototype = { } - var newViewportBounds = this.viewerElementToViewportRectangle(newBounds); + var constraintApplied = xConstrained || yConstrained; + var newViewportBounds = constraintApplied ? this.viewerElementToViewportRectangle(newBounds) : bounds.clone(); newViewportBounds.xConstrained = xConstrained; newViewportBounds.yConstrained = yConstrained; - newViewportBounds.constraintApplied = xConstrained || yConstrained; + newViewportBounds.constraintApplied = constraintApplied; return newViewportBounds; }, diff --git a/test/modules/viewport.js b/test/modules/viewport.js index 1e4c91f8..69344515 100644 --- a/test/modules/viewport.js +++ b/test/modules/viewport.js @@ -539,7 +539,7 @@ var bounds = viewport.getBounds(); Util.assertRectangleEquals( assert, - new OpenSeadragon.Rect(1.2071067811865466, 0.20710678118654746, Math.sqrt(2), Math.sqrt(2), 45), + new OpenSeadragon.Rect(1.0, 0.0, Math.sqrt(2), Math.sqrt(2), 45), bounds, EPSILON, "Viewport.applyConstraints with rotation should move viewport."); @@ -564,7 +564,7 @@ var bounds = viewport.getBounds(); Util.assertRectangleEquals( assert, - new OpenSeadragon.Rect(1.2071067811865466, 0.20710678118654746, Math.sqrt(2), Math.sqrt(2), 45), + new OpenSeadragon.Rect(1.0, 0.0, Math.sqrt(2), Math.sqrt(2), 45), bounds, EPSILON, "Viewport.applyConstraints flipped and with rotation should move viewport.");