Fix: make event.target the actual target where pan started #942
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, this is a Fix for Issue #815. I have tested the changes on Chrome (49.0.2623.87), Firefox (44.0.2), and Safari (9.0.3) using the demo kindly provided by @LeJared. Changes are local to only
src/recognizers/pan.js
andtests/manual/panstart.html
.Any feedback is appreciated! Please let me know if I should change or clarify anything. Thanks so much for your time. :)
Before,
event.target
is set to the element where the mouse pointer is at, after it has moved at leastPanRecognizer.options.threshold
pixels away from themousedown
position. This would normally not be a problem if the target element's size is greater thanthreshold
pixels, as the mouse pointer would still be within the target element at the end of the pan gesture, thusevent.target
would still be set to the expected element.However, if the element we originally panned over is smaller than
threshold
pixels, by the time the pan gesture has been recognized, the mouse pointer would be over a different element, not the original element ofpanstart
(not what we want).Now, the
event.target
of the pan gesture is set to where the user originally clicked (onpanstart
), as expected. This is done by saving the original target element, and updating the input before emitting it to the listeners.