Fix navigator flip transformation

Flip transformation wasn't correctly applied on navigator for all images when its tileSource is flipped by default.
This commit is contained in:
Nelson Campos 2018-10-18 11:31:55 +01:00
parent 132c68c8bb
commit 2670f62892
6 changed files with 11 additions and 8 deletions

View File

@ -509,7 +509,7 @@ $.Drawer.prototype = {
}); });
} }
if((this.viewport.degrees == 0 && tiledImage.getRotation(true) % 360 !== 0) || (this.viewport.degrees !== 0 && tiledImage.getRotation(true) % 360 == 0)){ if((this.viewport.degrees == 0 && tiledImage.getRotation(true) % 360 !== 0) || (this.viewport.degrees !== 0 && tiledImage.getRotation(true) % 360 == 0)){
if((this.viewport.getFlip() && !tiledImage.flipped) || (!this.viewport.getFlip() && tiledImage.flipped) ) { if((this.viewport.getFlip() && !tiledImage.getFlip()) || (!this.viewport.getFlip() && tiledImage.getFlip()) ) {
this._flip(); this._flip();
} }
} }
@ -648,7 +648,7 @@ $.Drawer.prototype = {
context.translate(point.x, point.y); context.translate(point.x, point.y);
// If viewport and tiledImage are flipped, it would draw the image without flipping // If viewport and tiledImage are flipped, it would draw the image without flipping
// This if sentence is intended to represent a logical XOR // This if sentence is intended to represent a logical XOR
if((!this.viewer.viewport.getFlip() && this.viewer.world._items[0].flipped) || (this.viewer.viewport.getFlip() && !this.viewer.world._items[0].flipped)){ if((!this.viewer.viewport.getFlip() && this.viewer.world._items[0].getFlip()) || (this.viewer.viewport.getFlip() && !this.viewer.world._items[0].getFlip())){
context.rotate(Math.PI / 180 * -options.degrees); context.rotate(Math.PI / 180 * -options.degrees);
context.scale(-1, 1); context.scale(-1, 1);
} else{ } else{

View File

@ -351,8 +351,6 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
style.height = Math.round( Math.max( height, 0 ) ) + 'px'; style.height = Math.round( Math.max( height, 0 ) ) + 'px';
} }
}, },
// overrides Viewer.addTiledImage // overrides Viewer.addTiledImage
@ -456,6 +454,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.getFlip() && !this.world._items[0].getFlip()) || (!this.viewer.viewport.getFlip() && this.world._items[0].getFlip())) { if((this.viewer.viewport.getFlip() && !this.world._items[0].getFlip()) || (!this.viewer.viewport.getFlip() && this.world._items[0].getFlip())) {
event.position.x = this.viewport.getContainerSize().x - event.position.x; event.position.x = this.viewport.getContainerSize().x - event.position.x;

View File

@ -271,7 +271,7 @@
* events between different devices, causing the faster devices to slow down enough to make the zoom control * events between different devices, causing the faster devices to slow down enough to make the zoom control
* more manageable. * more manageable.
* *
* @property {Number} [rotationIncrement=10] * @property {Number} [rotationIncrement=90]
* The number of degrees to rotate right or left when the rotate buttons or keyboard shortcuts are activated. * The number of degrees to rotate right or left when the rotate buttons or keyboard shortcuts are activated.
* *
* @property {Number} [pixelsPerWheelLine=40] * @property {Number} [pixelsPerWheelLine=40]

View File

@ -1902,6 +1902,7 @@ function drawTiles( tiledImage, lastDrawn ) {
} }
tiledImage._drawer._clear(true, bounds); tiledImage._drawer._clear(true, bounds);
} }
// When scaling, we must rotate only when blending the sketch canvas to // When scaling, we must rotate only when blending the sketch canvas to
// avoid interpolation // avoid interpolation
if (!sketchScale) { if (!sketchScale) {
@ -2044,7 +2045,6 @@ function drawTiles( tiledImage, lastDrawn ) {
} }
} }
drawDebugInfo( tiledImage, lastDrawn ); drawDebugInfo( tiledImage, lastDrawn );
} }

View File

@ -2679,7 +2679,6 @@ function onCanvasClick( event ) {
this.canvas.focus(); this.canvas.focus();
} }
if((this.viewport.getFlip() && !this.world._items[0].getFlip()) || (!this.viewport.getFlip() && this.world._items[0].getFlip())){ if((this.viewport.getFlip() && !this.world._items[0].getFlip()) || (!this.viewport.getFlip() && this.world._items[0].getFlip())){
console.log("FLipped Click");
event.position.x = this.viewport.getContainerSize().x - event.position.x; event.position.x = this.viewport.getContainerSize().x - event.position.x;
} }
@ -3367,6 +3366,10 @@ function updateOnce( viewer ) {
THIS[ viewer.hash ].animating = animated; THIS[ viewer.hash ].animating = animated;
// Update navigator flip transformation
if (viewer.navigator && viewer.viewport != "undefined"){
viewer.navigator.setFlip(viewer.viewport.getFlip());
}
//viewer.profiler.endUpdate(); //viewer.profiler.endUpdate();
} }

View File

@ -1552,7 +1552,8 @@ $.Viewport.prototype = {
this.flipped = state; this.flipped = state;
if(this.viewer.navigator){ if(this.viewer.navigator){
this.viewer.navigator.setFlip(this.getFlip()); var flip = ((this.getFlip() || !this.viewer.world._items[0].getFlip()) || (!this.getFlip() || this.viewer.world._items[0].getFlip()));
this.viewer.navigator.setFlip(flip);
} }
this.viewer.forceRedraw(); this.viewer.forceRedraw();