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();
|
viewportTL = rotatedBounds.getTopLeft();
|
||||||
viewportBR = rotatedBounds.getBottomRight();
|
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
|
//Don't draw if completely outside of the viewport
|
||||||
if ( !drawer.wrapHorizontal &&
|
if ( !drawer.wrapHorizontal &&
|
||||||
|
@ -241,7 +241,7 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
|
|||||||
(this.container.clientHeight === 0 ? 1 : this.container.clientHeight)
|
(this.container.clientHeight === 0 ? 1 : this.container.clientHeight)
|
||||||
);
|
);
|
||||||
if ( !containerSize.equals( this.oldContainerSize ) ) {
|
if ( !containerSize.equals( this.oldContainerSize ) ) {
|
||||||
var oldBounds = this.viewport.getBounds().rotate(this.viewport.degrees);
|
var oldBounds = this.viewport.getBounds();
|
||||||
var oldCenter = this.viewport.getCenter();
|
var oldCenter = this.viewport.getCenter();
|
||||||
this.viewport.resize( containerSize, true );
|
this.viewport.resize( containerSize, true );
|
||||||
var imageHeight = 1 / this.source.aspectRatio;
|
var imageHeight = 1 / this.source.aspectRatio;
|
||||||
|
@ -194,7 +194,7 @@ $.Rect.prototype = /** @lends OpenSeadragon.Rect.prototype */{
|
|||||||
newTopLeft;
|
newTopLeft;
|
||||||
|
|
||||||
degrees = ( degrees + 360 ) % 360;
|
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.');
|
throw new Error('Currently only 0, 90, 180, and 270 degrees are supported.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -713,10 +713,7 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Currently only 90 degree rotation is supported and it only works
|
* Rotates this viewport to the angle specified.
|
||||||
* with the canvas. Additionally, the navigator does not rotate yet,
|
|
||||||
* debug mode doesn't rotate yet, and overlay rotation is only
|
|
||||||
* partially supported.
|
|
||||||
* @function
|
* @function
|
||||||
* @return {OpenSeadragon.Viewport} Chainable.
|
* @return {OpenSeadragon.Viewport} Chainable.
|
||||||
*/
|
*/
|
||||||
@ -726,9 +723,6 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
}
|
}
|
||||||
|
|
||||||
degrees = ( degrees + 360 ) % 360;
|
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.degrees = degrees;
|
||||||
this.viewer.forceRedraw();
|
this.viewer.forceRedraw();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user