From 234801d2c4d73ab86100e2dca0a991826292eb23 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Mon, 26 Jun 2017 14:15:42 -0400 Subject: [PATCH 1/2] Unbind some event listeners for camera2d --- src/plots/gl2d/scene2d.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plots/gl2d/scene2d.js b/src/plots/gl2d/scene2d.js index 6c4da94cbd8..a1a1f77dc68 100644 --- a/src/plots/gl2d/scene2d.js +++ b/src/plots/gl2d/scene2d.js @@ -374,6 +374,9 @@ proto.destroy = function() { this.fullData = null; this.glplot = null; this.stopped = true; + this.camera.mouseListener.enabled = false; + this.mouseContainer.removeEventListener('wheel', this.camera.wheelListener); + this.camera = null; }; proto.plot = function(fullData, calcData, fullLayout) { From 888ee1b5be96533e446e63cdef6341d584952d38 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Mon, 26 Jun 2017 14:37:31 -0400 Subject: [PATCH 2/2] Remove scene3d camera listeners --- src/plots/gl3d/camera.js | 4 ++-- src/plots/gl3d/scene.js | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plots/gl3d/camera.js b/src/plots/gl3d/camera.js index 93d92e5ba08..29cdbec1eb5 100644 --- a/src/plots/gl3d/camera.js +++ b/src/plots/gl3d/camera.js @@ -181,7 +181,7 @@ function createCamera(element, options) { }); var lastX = 0, lastY = 0, lastMods = {shift: false, control: false, alt: false, meta: false}; - mouseChange(element, handleInteraction); + camera.mouseListener = mouseChange(element, handleInteraction); // enable simple touch interactions element.addEventListener('touchstart', function(ev) { @@ -247,7 +247,7 @@ function createCamera(element, options) { return true; } - mouseWheel(element, function(dx, dy) { + camera.wheelListener = mouseWheel(element, function(dx, dy) { if(camera.keyBindingMode === false) return; var flipX = camera.flipX ? 1 : -1; diff --git a/src/plots/gl3d/scene.js b/src/plots/gl3d/scene.js index fb550ed4a5d..1dee8b4917d 100644 --- a/src/plots/gl3d/scene.js +++ b/src/plots/gl3d/scene.js @@ -593,10 +593,11 @@ proto.plot = function(sceneData, fullLayout, layout) { }; proto.destroy = function() { + this.camera.mouseListener.enabled = false; + this.container.removeEventListener('wheel', this.camera.wheelListener); + this.camera = this.glplot.camera = null; this.glplot.dispose(); this.container.parentNode.removeChild(this.container); - - // Remove reference to glplot this.glplot = null; };