-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Recognizer Options of separate Hammer instances are mixed up (not separated) #813
Comments
…ons object into a new object upon instantiation hammerjs#813
I've created a bugfix for this issue. It ensures that the options are copied into a new object in the recognizer constructor. This fixes the actual issue. The deeper problem is in the So additionally replacing merge() in the constructor with a function that performs a deep copy would be recommended to avoid similar problems else where. |
@arschmitz sounds like we may leak options modifications between manager instances (not just recognizer instances), will investigate and PR fix if so. |
+1. Would like this to be merged. I have multiple instances of Hammer and need different directions listened. My temporary fix is to listen to all swipe directions but it's not ideal (especially for old devices). Thanks in advance |
Example:
http://codepen.io/anon/pen/bdYQaa
Expected behavior:
The first div is supposed to recognize Hammer.DIRECTION_ALL, the second one should recognize Hammer.DIRECTION_HORIZONTAL.
Actual behavior:
Both instances use Hammer.DIRECTION_HORIZONTAL.
When you inspect both instances in your JS debugger (Firebug, chrome dev tools, ...), you'll see, that the options of the panrecognizers of both instances are set to direction=6 (HORIZONTAL).
If you remove all the JS-code from the second instance, then the first instance is correctly set to Hammer.DIRECTION_ALL. Somehow setting this option on the second instance does also set this option on the first instance.
EDIT
Updated example. Now it outputs actual panrecognizer direction options of both instances
EDIT2
Update example. I've found, that the options-Object of two recognizer-instances are shared (identical objects). See output DIV in example. The options-objects are identical though the recognizer objects are not.
The text was updated successfully, but these errors were encountered: