From 6d829fcccfbffcbb7a40f112b110e68389a9f554 Mon Sep 17 00:00:00 2001 From: Todd Dembrey Date: Tue, 18 Feb 2020 13:26:00 +0000 Subject: [PATCH] fix: target listener became unbound when referenced, avoid unbinding (#64) --- src/CornerstoneViewport/CornerstoneViewport.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/CornerstoneViewport/CornerstoneViewport.js b/src/CornerstoneViewport/CornerstoneViewport.js index 6b7c216..1db82bc 100644 --- a/src/CornerstoneViewport/CornerstoneViewport.js +++ b/src/CornerstoneViewport/CornerstoneViewport.js @@ -489,10 +489,9 @@ class CornerstoneViewport extends Component { const events = cornerstoneEvents.concat(cornerstoneToolsEvents); const targetElementOrCornerstone = targetType === 'element' ? this.element : cornerstone.events; - const targetListener = targetElementOrCornerstone[addOrRemoveEventListener]; const boundMethod = this._handleExternalEventListeners.bind(this); for (let i = 0; i < events.length; i++) { - targetListener(events[i], boundMethod); + targetElementOrCornerstone[addOrRemoveEventListener](events[i], boundMethod); } }