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) { 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; };