Closed oufresh closed 5 years ago
Hello,
I'm using d3-zoom 1.7.3 and d3 5.5. Which is the correct way to disable the zoom behaviour applied to a selection? I would like to enable and disable it on my svg runtime with a switch.
the init funcion is:
initZoom(scale, x, y) { this.zoom = d3Zoom().scaleExtent(scaleExtent); this.svg.call(this.zoom); this.zoom.on("zoom", this.zoomed); this.svg.call( this.zoom.transform, zoomIdentity.translate(x, y).scale(scale) ); }
To enable/disable depending on a flag is correct to do:
if (enableZoom == true && this.zoom == null) { this.initZoom( this.props.transform.currentExpScale, this.props.transform.transformX, this.props.transform.transformY ); } if (enableZoom == false && this.zoom != null) { this.zoom.on("zoom", null); this.svg.on(".zoom", null); this.zoom = null; }
or there are problems with memory leaks, eventListeners and so on?
Thank you very much.
oufresh
Per the README, you can remove the zoom listeners like so:
selection.on(".zoom", null);
Hello,
I'm using d3-zoom 1.7.3 and d3 5.5. Which is the correct way to disable the zoom behaviour applied to a selection? I would like to enable and disable it on my svg runtime with a switch.
the init funcion is:
To enable/disable depending on a flag is correct to do:
or there are problems with memory leaks, eventListeners and so on?
Thank you very much.
oufresh