diff --git a/src/drawer.js b/src/drawer.js index 0165d1f3..34cf3506 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -403,6 +403,16 @@ function updateViewport( drawer ) { viewportTL = rotatedBounds.getTopLeft(); 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; + viewportBounds.width += orthBounds.width; + viewportBounds.height += orthBounds.height; + viewportTL = viewportBounds.getTopLeft(); + viewportBR = viewportBounds.getBottomRight(); + } //Don't draw if completely outside of the viewport if ( !drawer.wrapHorizontal && 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 99172e7d..4e3746eb 100644 --- a/src/rectangle.js +++ b/src/rectangle.js @@ -194,7 +194,7 @@ $.Rect.prototype = /** @lends OpenSeadragon.Rect.prototype */{ newTopLeft; degrees = ( degrees + 360 ) % 360; - if( degrees % 90 !== 0 ) { + if (degrees % 90 !== 0) { throw new Error('Currently only 0, 90, 180, and 270 degrees are supported.'); } diff --git a/src/viewport.js b/src/viewport.js index e1231500..4de54f96 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -713,10 +713,7 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{ }, /** - * Currently only 90 degree rotation is supported and it only works - * with the canvas. Additionally, the navigator does not rotate yet, - * debug mode doesn't rotate yet, and overlay rotation is only - * partially supported. + * Rotates this viewport to the angle specified. * @function * @return {OpenSeadragon.Viewport} Chainable. */ @@ -726,9 +723,6 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{ } degrees = ( degrees + 360 ) % 360; - if( degrees % 90 !== 0 ) { - throw new Error('Currently only 0, 90, 180, and 270 degrees are supported.'); - } this.degrees = degrees; this.viewer.forceRedraw();