-
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
Tap doesn't always fire in iOS #776
Comments
You need to use the "More Complex" implementation of hammer.js 2.0 that lets you delegate, and choose which events you do and don't intercept, or what to do in the cases where you do want them. I've found that this is easer to do thus far when NOT using jQuery, and rather implementing hammer.js as straight Javascript. |
Just to be clear, I'm not using the Hammer jQuery plugin, I'm just using both Hammer and jQuery on the same page. I've tried with the "More Complex" implementation with the following results: Hammer Manager with no recognizers: var bodyHammerManager = new Hammer.Manager(document.body, { Result: taps work great, but (obviously) Hammer events don't work. Hammer Manager with Swipe recogniser: var bodyHammerManager = new Hammer.Manager(document.body, { Result: taps fail about 50% of the time. I think they fail as soon as I move my finger even the slightest bit during the tap. Again, this only fails on iOS, other platforms don't have any problems. Final try So I thought: well, perhaps the Swipe picks up all the taps and thinks they are swipes. So I changed some options that made it impossible for me to launch the Swipe events (so the options do work). var bodyHammerManager = new Hammer.Manager(document.body, { Result: unfortunately, no difference with the previous test. Taps still fail a lot, as soon as my finger moves a little. If you want I can set up a test case, it's basically just a page with a link with a jQuery click event + the hammer code posted above. And again: this only fails in iOS. |
Alright, I found a (dirty, dirty) hack that seems to work: In the SwipeRecognizer inherit function, I changed: getTouchAction: function() { Into: getTouchAction: function() { Now all my click events work perfectly again, and swipe still works as well. That code must be there for a reason, so I know bypassing it is a dirty hack. If you have a better suggestion, I'd be very interested. |
I had the same problem and I was able to fix it by setting the Tap event's
After that, all tap events were triggering as expected. Hope it solves your issue as well. |
I've ran into this problem too. It seems to have something todo with the scrollbar on iOS. Whenever I swipe down (gesture up) the scrollbar shows, while scrolling (and scrollbar still shown) I try to tap something, nothing happens. If I tap again, because it felt like nothing happend, both taps are being triggered. The new and old (while scrolling one). If I tap on an item after the scrollbar disappeared again it works as expected. Tried to fix it with delegation, but didn't solve the problem either. The solution of @markuso didn't help for me unfortunately. |
Even worse, if I hit the scroll-tap bug and I wait exactly 10 seconds, it will trigger the tap anyway. So I either tap something or wait 10 seconds and it will trigger the tap anyway. After debugging this from the events up to the root cause, it seems the Bluebird Promise isn't being resolved for some strange reason. Debugging on that now, but for the matter of this issue; invalid. (petkaantonov/bluebird#666) |
@markuso Thanks!!! finally it works in android and iphone after 1 day of research |
I am using jQuery click events, no problems on all devices. Then I added hammer.js listeners on the body element for swipe, pan and drag functionality.
Unfortunately, this broke the click events on iOS: they fire only 90% of the time in iOS, other platforms (Android and PC) still work perfectly.
When the click event doesn't fire, it still sets the button to "active" (CSS), meaning the device registered the click, but somehow hammer stopped it from firing.
Thing's I've tried to fix it (without result):
Is there any way to use hammer.js, but totally ignore/bypass the tap event?
The text was updated successfully, but these errors were encountered: