mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-29 00:26:10 +03:00
Merge pull request #466 from PathXL/free-hand-rotation
Allow all rotation angles
This commit is contained in:
commit
ff2e0a1c55
@ -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 &&
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user