From e00e4c53ef5d38cfabf7bbad841fb665648f559c Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Tue, 19 Aug 2014 09:51:27 +0100 Subject: [PATCH] Proper viewport bounds changes for rotation. --- src/drawer.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/drawer.js b/src/drawer.js index 5e4b59b7..64d2b671 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -404,18 +404,15 @@ function updateViewport( drawer ) { viewportBR = rotatedBounds.getBottomRight(); } else if (degrees !== 0) { - /* - var factor1 = drawer.viewer.viewport.imageToViewportRectangle(0, 0, 256, 256); - viewportBounds.width += factor1.width; - viewportBounds.height += factor1.width; + var orthBounds = viewportBounds.rotate(90); + var halfWidth = orthBounds.width / 2; + var halfHeight = orthBounds.height / 2; + viewportBounds.x -= halfWidth / 2; + viewportBounds.y -= halfHeight / 2; + viewportBounds.width += halfWidth; + viewportBounds.height += halfHeight; viewportTL = viewportBounds.getTopLeft(); viewportBR = viewportBounds.getBottomRight(); - */ - var factor = 0.3 / drawer.viewer.viewport.getZoom(); - viewportTL.x -= factor; - viewportTL.y -= factor; - viewportBR.x += factor; - viewportBR.y += factor; } //Don't draw if completely outside of the viewport