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.