jquery / jquery-simulate

jQuery Event Unit Testing Helpers
Other
173 stars 114 forks source link

Why is there a click event after simulate drag? #11

Closed pscheit closed 11 years ago

pscheit commented 11 years ago

Hello Everyone,

i just want to pull this to make a point. Why is there an aditional click event triggered? Normally dragigng is just: mousedown - moveit - mouseup isn't it?

Is some strange browser doing this?

best regards Philipp

mikesherov commented 11 years ago

@pscheit, no, it isn't. If you hold down your mouse, drag, and then mouseup, the click event gets fired right after.

mikesherov commented 11 years ago

@pscheit, thanks for contributing and taking the time to provide a patch though. Please feel free to peruse the open issues, and provide patches for any open issues.

gnarf commented 11 years ago

@mikesherov assuming you mouseup in the same element you mousedown'ed and there aren't any preventDefault's involved... :)

mikesherov commented 11 years ago

@gnarf37, which is what simulateDrag intends to emulate :-)

mikesherov commented 11 years ago

@gnarf37, certainly it make be made way less brittle. I suppose we should check that the mouse is within the same element.

pscheit commented 11 years ago

this maybe off-topic, it may be related:

i have the case, that when i use simulate, my application gets with the following code to the click event: when i use my own mouse (firefox 18.0.1 windows) the click event is not triggered:

this is triggered (while dragging) with simulate, and isnt triggered (while dragging) with mouse

$someDiv.on('click', '.child-element-class', function (e) {
  var $childElement = $(e.currentTarget);
});

this isn't triggered (while dragging) with simulate, and isnt triggered (while draggin) with mouse

$someDiv.on('click', function (e) {
  var $childElement = $(e.target);
  if ($childElement.is('.child-element-class')) {
  }
});

i expect both pieces of code to trigger or not to trigger consistent with mouse

thank you for your clarification anyway!

mikesherov commented 11 years ago

@pscheit, that may be a legitimate bug. Please file a new issue for that with a full test case showing the HTML you've used as well. Thanks agian!