From 78c6295acfc366a3a1bd83b675f15ba30e0a4680 Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 2 Dec 2022 22:08:15 -0500 Subject: [PATCH] update unit tests --- src/viewport.js | 5 +++-- test/modules/viewport.js | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) 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.");