From ea80c05a05f2693f8df2ca88debca269ef40bc9a Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Wed, 20 Aug 2014 09:21:02 +0100 Subject: [PATCH] Replace error for non right-angle rotations in Rect.rotate. --- src/drawer.js | 1 + src/navigator.js | 2 +- src/rectangle.js | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/drawer.js b/src/drawer.js index 248266ba..34cf3506 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -404,6 +404,7 @@ function updateViewport( drawer ) { viewportBR = rotatedBounds.getBottomRight(); } else if (degrees !== 0) { + // This is just an approximation. var orthBounds = viewportBounds.rotate(90); viewportBounds.x -= orthBounds.width / 2; viewportBounds.y -= orthBounds.height / 2; diff --git a/src/navigator.js b/src/navigator.js index d07a2bba..9e18d6ca 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -241,7 +241,7 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /* (this.container.clientHeight === 0 ? 1 : this.container.clientHeight) ); if ( !containerSize.equals( this.oldContainerSize ) ) { - var oldBounds = this.viewport.getBounds().rotate(this.viewport.degrees); + var oldBounds = this.viewport.getBounds(); var oldCenter = this.viewport.getCenter(); this.viewport.resize( containerSize, true ); var imageHeight = 1 / this.source.aspectRatio; diff --git a/src/rectangle.js b/src/rectangle.js index b518190e..1bac049f 100644 --- a/src/rectangle.js +++ b/src/rectangle.js @@ -195,6 +195,11 @@ $.Rect.prototype = /** @lends OpenSeadragon.Rect.prototype */{ degrees = ( degrees + 360 ) % 360; + if (degrees % 90 !== 0) + { + throw new Error('Currently only 0, 90, 180, and 270 degrees are supported.'); + } + if( degrees === 0 ){ return new $.Rect( this.x,