code simplification and impro^Cments on toggleFlip function

This commit is contained in:
Nelson Campos 2018-04-11 18:24:01 +01:00
parent b8a4f7e7a0
commit 84dc60632c
4 changed files with 16 additions and 5 deletions

View File

@ -276,8 +276,8 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
/**
/* Flip navigator element
*/
toggleFlip: function() {
this.viewport.flipped = !this.viewport.flipped;
setFlip: function() {
this.viewport.toggleFlip();
this.setDisplayTransform(this.viewer.viewport.flipped ? "scale(-1,1)" : "scale(1,1)");
this.viewport.viewer.forceRedraw();

View File

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

View File

@ -367,6 +367,7 @@ $.Viewer = function( options ) {
maxZoomLevel: this.maxZoomLevel,
viewer: this,
degrees: this.degrees,
flipped: this.flipped,
navigatorRotate: this.navigatorRotate,
homeFillsViewer: this.homeFillsViewer,
margins: this.viewportMargins

View File

@ -1525,12 +1525,19 @@ $.Viewport.prototype = {
* Toggle flip state and demands a new drawing on navigator and viewer objects.
*/
toggleFlip: function() {
this.flipped = !this.flipped;
this.setFlip(!this.getFlip());
if(this.viewer.navigator){
this.viewer.navigator.toggleFlip();
this.viewer.navigator.setFlip();
}
this.viewer._forceRedraw = !this.viewer._forceRedraw;
this.viewer.forceRedraw();
},
getFlip: function() {
return this.flipped;
},
setFlip: function( state ) {
this.flipped = state;
}
};