D3 Differentiate between click and drag for an element which has a drag behavior

后端 未结 3 1562
盖世英雄少女心
盖世英雄少女心 2020-11-27 19:45

I am unable to successfully distinguish between the click event and the drag event on an element that is bound to both using D3.js v3. The circle

3条回答
  •  醉话见心
    2020-11-27 20:05

    The key bit that's missing is the check whether the default behaviour of an event has been prevented. That is, there's a matching sibling to d3.event.preventDefault() -- d3.event.defaultPrevented. You need to check this in your click handler to see whether any dragging action is going on.

    See also the answer to this question.

提交回复
热议问题