block by mbostock a84aeb78fea81e1ad806

Click vs. Drag

Full Screen

This example demonstrates how to disambiguate a click from a drag gesture using d3.event.defaultPrevented. Drag any circle to change its position, or click it to briefly inflate.

Note that you must be careful not to re-append the element on dragstart (mousedown), as this may prevent the browser from dispatching a click event! Instead, defer the move-to-front until the first drag event.

Updated Example →

index.html