Code cleaning and function calls reorganization

This commit is contained in:
Nelson Campos 2018-04-12 18:24:11 +01:00
parent b7badc7d32
commit c2fd5322e2
3 changed files with 15 additions and 10 deletions

View File

@ -275,12 +275,13 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
},
/**
/* Flip navigator element
* @param {Boolean} state - Flip state to set.
*/
setFlip: function() {
this.viewport.toggleFlip();
setFlip: function(state) {
this.viewport.setFlip(state);
this.setDisplayTransform(this.viewer.viewport.flipped ? "scale(-1,1)" : "scale(1,1)");
this.viewport.viewer.forceRedraw();
this.setDisplayTransform(this.viewer.viewport.getFlip() ? "scale(-1,1)" : "scale(1,1)");
return this;
},
setDisplayTransform: function(rule) {

View File

@ -206,7 +206,7 @@
* @property {Number} [degrees=0]
* Initial rotation.
*
* @property {Boolean} [flip=false]
* @property {Boolean} [flipped=false]
* Initial flip state.
*
* @property {Number} [minZoomLevel=null]

View File

@ -1528,10 +1528,6 @@ $.Viewport.prototype = {
*/
toggleFlip: function() {
this.setFlip(!this.getFlip());
if(this.viewer.navigator){
this.viewer.navigator.setFlip();
}
this.viewer.forceRedraw();
return this;
},
@ -1554,6 +1550,9 @@ $.Viewport.prototype = {
*/
setFlip: function( state ) {
if ( this.flipped != state ) {
this.flipped = state;
this.viewer.forceRedraw();
/**
* Raised when flip state has been changed.
*
@ -1565,9 +1564,14 @@ $.Viewport.prototype = {
* @property {?Object} userData - Arbitrary subscriber-defined object.
*/
this.viewer.raiseEvent('flip', {"flipped": state});
} else {
this.flipped = state;
}
this.flipped = state;
if(this.viewer.navigator){
this.viewer.navigator.setFlip(this.getFlip());
}
this.viewer.forceRedraw();
return this;
}