How to remove d3.behavior.drag().on(“drag”,…) event handler [duplicate]

久未见 提交于 2019-12-12 16:10:36

问题


I have the following attached to a svg element

var dragger = d3.behavior.drag()
.origin(function(d) {
  return d;
})
.on('drag', this.move)
.on('dragend', dropHandler);

//caller
var g = c.append('svg').call(dragger).data([{
x: x0,
y: y0
}]);

I am implementing some code inside the dropHandler function that needs it's own implementation of .on("drag",..). How do I remove the previous event handler from the code?

I tried the following:

.unbind()
selection.on("drag",null);

回答1:


Found an answer: here

d3.select('rect#no-drag').on('mousedown.drag', null);


来源:https://stackoverflow.com/questions/38416661/how-to-remove-d3-behavior-drag-ondrag-event-handler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!