D3防止双击缩放 [英] D3 Prevent Double Click Zoom
本文介绍了D3防止双击缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个D3网络图,我试图禁用双击缩放功能。
我有它缩放使用:
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)
我也试过调用
.on("dblclick.zoom", null)
在svg元素本身,也不工作。
on the svg element by itself and that doesnt work either. Any help would be much appreciated.
推荐答案
您需要致电
.on("dblclick.zoom", null)
$ b b
之后
after
svg.call(zoom)
ie
svg.call(zoom).on("dblclick.zoom", null);
这篇关于D3防止双击缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文