From f2c8db5db0c2e5868437e634d12eae7b3c0df958 Mon Sep 17 00:00:00 2001 From: Tom Date: Sat, 27 Apr 2024 16:38:30 -0400 Subject: [PATCH 1/2] fix #2517 --- src/canvasdrawer.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/canvasdrawer.js b/src/canvasdrawer.js index e755c97b..1ec6a10b 100644 --- a/src/canvasdrawer.js +++ b/src/canvasdrawer.js @@ -80,8 +80,6 @@ class CanvasDrawer extends OpenSeadragon.DrawerBase{ // Canvas default is "true", so this will only be changed if user specifies "false" in the options or via setImageSmoothinEnabled. this._imageSmoothingEnabled = true; - this._viewportFlipped = false; - // Since the tile-drawn and tile-drawing events are fired by this drawer, make sure handlers can be added for them this.viewer.allowEventHandler("tile-drawn"); this.viewer.allowEventHandler("tile-drawing"); @@ -118,8 +116,8 @@ class CanvasDrawer extends OpenSeadragon.DrawerBase{ this._prepareNewFrame(); // prepare to draw a new frame if(this.viewer.viewport.getFlip() !== this._viewportFlipped){ this._flip(); - this._viewportFlipped = !this._viewportFlipped; } + console.log('draw', this._viewportFlipped); for(const tiledImage of tiledImages){ if (tiledImage.opacity !== 0) { this._drawTiles(tiledImage); @@ -189,6 +187,10 @@ class CanvasDrawer extends OpenSeadragon.DrawerBase{ context.restore(); } + get _viewportFlipped(){ + return this.context.getTransform().a < 0; + } + /** * Fires the tile-drawing event. * @private @@ -961,6 +963,7 @@ class CanvasDrawer extends OpenSeadragon.DrawerBase{ context.translate(point.x, 0); context.scale(-1, 1); context.translate(-point.x, 0); + console.log('flipped'); } // private From 9d6a785aacc8158bb3a1b25391b32b650782db0e Mon Sep 17 00:00:00 2001 From: Tom Date: Sat, 27 Apr 2024 16:41:18 -0400 Subject: [PATCH 2/2] add comment; clean up console.log messages from testing --- src/canvasdrawer.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/canvasdrawer.js b/src/canvasdrawer.js index 1ec6a10b..57525e37 100644 --- a/src/canvasdrawer.js +++ b/src/canvasdrawer.js @@ -117,7 +117,6 @@ class CanvasDrawer extends OpenSeadragon.DrawerBase{ if(this.viewer.viewport.getFlip() !== this._viewportFlipped){ this._flip(); } - console.log('draw', this._viewportFlipped); for(const tiledImage of tiledImages){ if (tiledImage.opacity !== 0) { this._drawTiles(tiledImage); @@ -187,6 +186,10 @@ class CanvasDrawer extends OpenSeadragon.DrawerBase{ context.restore(); } + /** + * Test whether the current context is flipped or not + * @private + */ get _viewportFlipped(){ return this.context.getTransform().a < 0; } @@ -963,7 +966,6 @@ class CanvasDrawer extends OpenSeadragon.DrawerBase{ context.translate(point.x, 0); context.scale(-1, 1); context.translate(-point.x, 0); - console.log('flipped'); } // private