我必须在d3-v4中禁用鼠标左键的平移,它应该只使用鼠标右键平移。我的下面的代码是在d3-v3中工作但不在v4中
this.zoomListener = d3.zoom().on("start", this.zoomstart.bind(this)).on("zoom", this.zoom.bind(this)).on("end", this.zoomend.bind(this));
const eventProxy = (fn: any) => {
return () => {
// Enable events if enableEvents=== true
if (d3.event.which === 3) {
fn.apply(this, arguments);
}
};
};
this.parentSvg.call(this.zoomListener).on("dblclick.zoom", null);
const mouseDownTarget = this.parentSvg.on("mousedown.zoom");
this.parentSvg.on("mousedown.zoom", eventProxy(mouseDownTarget));
有人知道如何在V4中这样做吗