From f3b92e0562cceb50480d4074896d77782f7bf5c2 Mon Sep 17 00:00:00 2001 From: Tom Date: Thu, 15 Aug 2024 17:51:06 -0400 Subject: [PATCH 1/2] remove resize handler when webgl drawer is destroyed --- src/webgldrawer.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/webgldrawer.js b/src/webgldrawer.js index ed1f30ab..cf489661 100644 --- a/src/webgldrawer.js +++ b/src/webgldrawer.js @@ -160,6 +160,7 @@ // unbind our event listeners from the viewer this.viewer.removeHandler("tile-ready", this._boundToTileReady); this.viewer.removeHandler("image-unloaded", this._boundToImageUnloaded); + this.viewer.removeHandler("resize", this._resizeHandler); // set our webgl context reference to null to enable garbage collection this._gl = null; @@ -839,8 +840,7 @@ this._gl = this._renderingCanvas.getContext('webgl'); - //make the additional canvas elements mirror size changes to the output canvas - this.viewer.addHandler("resize", function(){ + this._resizeHandler = function(){ if(_this._outputCanvas !== _this.viewer.drawer.canvas){ _this._outputCanvas.style.width = _this.viewer.drawer.canvas.clientWidth + 'px'; @@ -861,7 +861,10 @@ // important - update the size of the rendering viewport! _this._resizeRenderer(); - }); + }; + + //make the additional canvas elements mirror size changes to the output canvas + this.viewer.addHandler("resize", this._resizeHandler); } // private From a10b9086ab625f8acdc98a3fd46a78b7c5cebf95 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Fri, 16 Aug 2024 09:39:04 -0700 Subject: [PATCH 2/2] Changelog for #2570 --- changelog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.txt b/changelog.txt index 08023eaa..27c5e976 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,8 @@ OPENSEADRAGON CHANGELOG 5.0.1: (in progress...) +* Fixed: If you switched from WebGL drawer to canvas drawer, it didn't clean up properly (#2570 @pearcetm) + 5.0.0: * BREAKING CHANGE: Dropped support for IE11 (#2300, #2361, #2553 @AndrewADev, @msalsbery)