mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-01-31 23:21:42 +03:00
Revisions to rotate after second code review.
This commit is contained in:
parent
54e8d8c43f
commit
767c897e7f
@ -403,6 +403,10 @@ $.Drawer.prototype = {
|
||||
}
|
||||
|
||||
return loading;
|
||||
},
|
||||
|
||||
canRotate: function() {
|
||||
return USE_CANVAS;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -182,7 +182,12 @@ $.Rect.prototype = {
|
||||
}
|
||||
|
||||
if( degrees === 0 ){
|
||||
return this;
|
||||
return new $.Rect(
|
||||
this.x,
|
||||
this.y,
|
||||
this.width,
|
||||
this.height
|
||||
);
|
||||
}
|
||||
|
||||
pivot = pivot || this.getCenter();
|
||||
|
@ -533,7 +533,7 @@ $.Viewport.prototype = {
|
||||
* @return {OpenSeadragon.Viewport} Chainable.
|
||||
*/
|
||||
zoomBy: function( factor, refPoint, immediately ) {
|
||||
if( typeof refPoint != 'undefined' ) {
|
||||
if( refPoint ) {
|
||||
refPoint = refPoint.rotate(
|
||||
-this.degrees,
|
||||
new $.Point( this.centerSpringX.target.value, this.centerSpringY.target.value )
|
||||
@ -574,19 +574,35 @@ $.Viewport.prototype = {
|
||||
* Currently only supports 90 degree rotation.
|
||||
* Currently only works with canvas.
|
||||
* @function
|
||||
* @name OpenSeadragon.Viewport.prototype.rotate
|
||||
* @name OpenSeadragon.Viewport.prototype.setRotation
|
||||
* @return {OpenSeadragon.Viewport} Chainable.
|
||||
*/
|
||||
setRotation: function(degrees){
|
||||
setRotation: function( degrees ) {
|
||||
if( !( this.viewer && this.viewer.drawer.canRotate() ) ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
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.');
|
||||
}
|
||||
this.degrees = degrees;
|
||||
this.viewer.drawer.update();
|
||||
if( this.viewer ) {
|
||||
this.viewer.drawer.update();
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the current rotation in degrees.
|
||||
* @function
|
||||
* @name OpenSeadragon.Viewport.prototype.setRotation
|
||||
* @return {Number} The current rotation in degrees.
|
||||
*/
|
||||
getRotation: function() {
|
||||
return this.degrees;
|
||||
},
|
||||
|
||||
/**
|
||||
* @function
|
||||
* @return {OpenSeadragon.Viewport} Chainable.
|
||||
|
Loading…
x
Reference in New Issue
Block a user