I have a D3 Network Graph and I am trying to disable the Double Click zoom function. I have it zooming using:
var zoom = d3.behavior.zoom().scaleExtent([minZoom, maxZoom]);
zoom.on("zoom", function() {
g.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
});
svg.call(zoom)
However I cant seem to be able to disable just the Double click zoom. When I use the code below it disables the zoom altogether.
var zoom = d3.behavior.zoom().scaleExtent([minZoom, maxZoom]);
zoom.on("zoom", function() {
g.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")").on("dblclick.zoom", null);
});
svg.call(zoom)
I have also tried calling
.on("dblclick.zoom", null)
on the svg element by itself and that doesnt work either. Any help would be much appreciated.
You need to call
.on("dblclick.zoom", null)
after
svg.call(zoom)
i.e.
svg.call(zoom).on("dblclick.zoom", null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With