As the title says, I have an object, and i need all it's drag and click events. There was some discussion about this issue, but it mainly concerned the click and drag events. (and a reply fiddle didnt work properly)
I have a fiddle here of where I am at. When I drag, click is prevented, but when I click the dragstart and end events fire. I'd like them not to fire when I click, and I'd like click not to fire when I want to drag.
var drag = d3.behavior.drag()
.origin(function(d){return d})
.on('drag', function(d){
d3.select(this).attr('cx', function(d){ return d.x += d3.event.dx });
d3.select(this).attr('cy', function(d){ return d.y += d3.event.dy });
console.log('dragging');
})
.on('dragstart', function(d){
d3.event.sourceEvent.stopPropagation()
console.log('drag start');
})
.on('dragend', function(d){
console.log('drag end');
})
// .....
MySvgElementWith3DStuffOnIt.on('click', function(){
if(d3.event.defaultPrevented) return;
console.log('clicked');
});