Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: make event.target the actual target where pan started #942

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix: make event.target the actual target where pan started #942

wants to merge 2 commits into from

Conversation

zoexi
Copy link
Contributor

@zoexi zoexi commented Mar 20, 2016

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 and tests/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 least PanRecognizer.options.threshold pixels away from the mousedown position. This would normally not be a problem if the target element's size is greater than threshold pixels, as the mouse pointer would still be within the target element at the end of the pan gesture, thus event.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 of panstart (not what we want).

Now, the event.target of the pan gesture is set to where the user originally clicked (on panstart), as expected. This is done by saving the original target element, and updating the input before emitting it to the listeners.

@zoexi zoexi changed the title Fix to make event.target the actual target where pan started Fix: make event.target the actual target where pan started Mar 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant