Refactored 90 degrees rotation button's actions.

This commit is contained in:
Nelson Campos 2018-04-17 11:19:15 +01:00
parent ec0f55098a
commit 43d3949dd1
2 changed files with 6 additions and 30 deletions

View File

@ -526,10 +526,4 @@ function setElementTransform( element, rule ) {
element.style.transform = rule; element.style.transform = rule;
} }
}( OpenSeadragon )); }( OpenSeadragon ));

View File

@ -3476,20 +3476,11 @@ function onFullScreen() {
function onRotateLeft() { function onRotateLeft() {
if ( this.viewport ) { if ( this.viewport ) {
var currRotation = this.viewport.getRotation(); var currRotation = this.viewport.getRotation();
if ( this.viewport.flipped ){ if ( this.viewport.flipped ){
if (currRotation === 270) { currRotation = $.positiveModulo(currRotation + 90, 360);
currRotation = 0;
}
else {
currRotation += 90;
}
} else { } else {
if (currRotation === 0) { currRotation = $.positiveModulo(currRotation - 90, 360);
currRotation = 270;
}
else {
currRotation -= 90;
}
} }
this.viewport.setRotation(currRotation); this.viewport.setRotation(currRotation);
} }
@ -3501,20 +3492,11 @@ function onRotateLeft() {
function onRotateRight() { function onRotateRight() {
if ( this.viewport ) { if ( this.viewport ) {
var currRotation = this.viewport.getRotation(); var currRotation = this.viewport.getRotation();
if ( this.viewport.flipped ){ if ( this.viewport.flipped ){
if (currRotation === 0) { currRotation = $.positiveModulo(currRotation - 90, 360);
currRotation = 270;
}
else {
currRotation -= 90;
}
} else { } else {
if (currRotation === 270) { currRotation = $.positiveModulo(currRotation + 90, 360);
currRotation = 0;
}
else {
currRotation += 90;
}
} }
this.viewport.setRotation(currRotation); this.viewport.setRotation(currRotation);
} }