raphael
raphael copied to clipboard
element.drag and element.click conflict
I got some trouble with binding a drag event and a click event on the same elements :
set.click( function(){
this.remove().clear();
});
set.drag(function(dx,dy){...},function(){...},function(){...});
when the drag end, the click event is catched ... any idea ?
@clawfire I am currently running into the same issue. Any solutions?
you can add click event to drag event in the third parameter "onend",I tested when I clicked the element,the drag event "onstart" & "onend" happend,and you can set a flag ,when the event through the "onmove" you can set change the flag,I sorry my english is so poor,I must paste the code.
var tz_tag = true;
elem.drag(function(dx,dy,x,y,event){
tz_tag = false;
},function(x,y,event){
//拖动开始
},function(event){
//拖动结束
if(tz_tag){
//do something
}
tz_tag = true;
});
I confirm this issue
I completely agree @YealZoy . Setting multiple events does nothing but appends the events into an array of events to be listened. Click is nothing but a mouseMove not being fired in the drag event.
@tobiascapin If we are stating this as an issue, then what should be the ideal behaviour for the snippet and what solution we might derive from it.
For me a click event is a fast mouseDown+mouseUp without mouseMove between these events. During my tests I found that a click event is fired at mouseup at the end of the drag, for me this is an issue. If I'm dragging I'm not cliccking.
Let's say that I select an element with click and I want to move selected element with drag, the effect is that at drag end I lose element selection because an unwanted click is fired on it (I made a workaround with a "isDragging" flag, with this flag I ignore a click if I'm dragging the element).