Fix navigator flipped drag and click handlers

This commit is contained in:
Nelson Campos 2018-10-17 11:09:45 +01:00
parent cf20d9fb43
commit bfd170689d
2 changed files with 9 additions and 9 deletions

View File

@ -455,7 +455,7 @@ function onCanvasClick( event ) {
this.viewer.raiseEvent('navigator-click', canvasClickEventArgs); this.viewer.raiseEvent('navigator-click', canvasClickEventArgs);
if ( !canvasClickEventArgs.preventDefaultAction && event.quick && this.viewer.viewport && (this.panVertical || this.panHorizontal)) { if ( !canvasClickEventArgs.preventDefaultAction && event.quick && this.viewer.viewport && (this.panVertical || this.panHorizontal)) {
if(this.viewer.viewport.flipped) { if((this.viewer.viewport.flipped && !this.world._items[0].flipped) || (!this.viewer.viewport.flipped && this.world._items[0].flipped)) {
event.position.x = this.viewport.getContainerSize().x - event.position.x; event.position.x = this.viewport.getContainerSize().x - event.position.x;
} }
var target = this.viewport.pointFromPixel(event.position); var target = this.viewport.pointFromPixel(event.position);
@ -515,7 +515,7 @@ function onCanvasDrag( event ) {
event.delta.y = 0; event.delta.y = 0;
} }
if(this.viewer.viewport.flipped){ if((this.viewer.viewport.flipped && !this.world._items[0].flipped) || (!this.viewer.viewport.flipped && this.world._items[0].flipped)) {
event.delta.x = -event.delta.x; event.delta.x = -event.delta.x;
} }

View File

@ -2642,7 +2642,7 @@ function onCanvasKeyPress( event ) {
} }
return false; return false;
case 114: //r - clockwise rotation case 114: //r - clockwise rotation
if(this.viewport.flipped){ if((this.viewport.flipped && !this.world._items[0].flipped) || (!this.viewport.flipped && this.world._items[0].flipped)){
this.viewport.setRotation($.positiveModulo(this.viewport.degrees - this.rotationIncrement, 360)); this.viewport.setRotation($.positiveModulo(this.viewport.degrees - this.rotationIncrement, 360));
} else{ } else{
this.viewport.setRotation($.positiveModulo(this.viewport.degrees + this.rotationIncrement, 360)); this.viewport.setRotation($.positiveModulo(this.viewport.degrees + this.rotationIncrement, 360));
@ -2650,7 +2650,7 @@ function onCanvasKeyPress( event ) {
this.viewport.applyConstraints(); this.viewport.applyConstraints();
return false; return false;
case 82: //R - counterclockwise rotation case 82: //R - counterclockwise rotation
if(this.viewport.flipped){ if((this.viewport.flipped && !this.world._items[0].flipped) || (!this.viewport.flipped && this.world._items[0].flipped)){
this.viewport.setRotation($.positiveModulo(this.viewport.degrees + this.rotationIncrement, 360)); this.viewport.setRotation($.positiveModulo(this.viewport.degrees + this.rotationIncrement, 360));
} else{ } else{
this.viewport.setRotation($.positiveModulo(this.viewport.degrees - this.rotationIncrement, 360)); this.viewport.setRotation($.positiveModulo(this.viewport.degrees - this.rotationIncrement, 360));
@ -2678,7 +2678,7 @@ function onCanvasClick( event ) {
if ( !haveKeyboardFocus ) { if ( !haveKeyboardFocus ) {
this.canvas.focus(); this.canvas.focus();
} }
if(this.viewport.flipped){ if((this.viewport.flipped && !this.world._items[0].flipped) || (!this.viewport.flipped && this.world._items[0].flipped)){
event.position.x = this.viewport.getContainerSize().x - event.position.x; event.position.x = this.viewport.getContainerSize().x - event.position.x;
} }
@ -2800,7 +2800,7 @@ function onCanvasDrag( event ) {
if( !this.panVertical ){ if( !this.panVertical ){
event.delta.y = 0; event.delta.y = 0;
} }
if(this.viewport.flipped){ if((this.viewport.flipped && !this.world._items[0].flipped) || (!this.viewport.flipped && this.world._items[0].flipped)){
event.delta.x = -event.delta.x; event.delta.x = -event.delta.x;
} }
@ -3128,7 +3128,7 @@ function onCanvasScroll( event ) {
if (deltaScrollTime > this.minScrollDeltaTime) { if (deltaScrollTime > this.minScrollDeltaTime) {
this._lastScrollTime = thisScrollTime; this._lastScrollTime = thisScrollTime;
if(this.viewport.flipped){ if((this.viewport.flipped && !this.world._items[0].flipped) || (!this.viewport.flipped && this.world._items[0].flipped)){
event.position.x = this.viewport.getContainerSize().x - event.position.x; event.position.x = this.viewport.getContainerSize().x - event.position.x;
} }
@ -3495,7 +3495,7 @@ 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 && !this.world._items[0].flipped) || (!this.viewport.flipped && this.world._items[0].flipped)){
currRotation = $.positiveModulo(currRotation + this.rotationIncrement, 360); currRotation = $.positiveModulo(currRotation + this.rotationIncrement, 360);
} else { } else {
currRotation = $.positiveModulo(currRotation - this.rotationIncrement, 360); currRotation = $.positiveModulo(currRotation - this.rotationIncrement, 360);
@ -3508,7 +3508,7 @@ 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 && !this.world._items[0].flipped) || (!this.viewport.flipped && this.world._items[0].flipped)){
currRotation = $.positiveModulo(currRotation - this.rotationIncrement, 360); currRotation = $.positiveModulo(currRotation - this.rotationIncrement, 360);
} else { } else {
currRotation = $.positiveModulo(currRotation + this.rotationIncrement, 360); currRotation = $.positiveModulo(currRotation + this.rotationIncrement, 360);