hammer.js: Swipe event doesn't work in Chrome 55.0
We use leftSwipe and rightSwipe to detect the event but neither of it works in Chrome with version higher than 55.0. But before it worked in Chrome 54.0 and version lower than 55.0. Also tried in Firefox and Safari, and both of them work fine.
hammer.add(new Hammer.Swipe({ event: "leftSwipe", direction: Hammer.DIRECTION_LEFT }));
hammer.add(new Hammer.Swipe({ event: "rightSwipe", direction: Hammer.DIRECTION_RIGHT }));
This problem can also be test here https://hammerjs.github.io/
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 11
- Comments: 30 (2 by maintainers)
Commits related to this issue
- Disable pointer-event support https://github.com/hammerjs/hammer.js/issues/1065 — committed to WoodyWoodsta/hammer.js by WoodyWoodsta 7 years ago
- Enable pointer events only when touch events unavailable (refs #1065) This fixes swipe events on elements with `overflow: auto` in mobile Chrome. — committed to 67P/hammer.js by galfert 7 years ago
- Fix menu swiping in Chrome Refs #63 This is using the fix suggested in https://github.com/hammerjs/hammer.js/issues/1065#issuecomment-285855090 instead of using our own patched version of hammerjs. — committed to 67P/hyperchannel by galfert 6 years ago
FYI
I’ve solved my problem (Swipe not working on Chrome 56 on Android) using this
I think this is due to chrome making touchEvents passive by default. Ill try to find time to lookinto this and fix this week
Hi. In our app we have a relative positioned header where swipe events works fine, the next element in the DOM is a
divwhich has the styleoverflow-y: auto;breaking the Hammer recognizer.This is only when using touch - doing the swipe action with the mouse does still work!
I had a div element that needed to be scrollable up/down and swipable left/right. None of the above suggestions fixed it… What helped instead was to put
to its child element and adding
to the hammerjs manager.
Might have to look at this any further: https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action
Strangely enough I also had issues with the swiping (and only the swiping event) on a div that had “overflow-y” set to “auto”. My Hammer was capturing directly on the body:
Hammer(document.body).on("swipe tap press", touchHandler);adding an empty event handler to my div solved the issue and now I can scroll up and down within the div and still swipe left and right to navigate:
Hope this helps someone!
You can try setting
{ inputClass: Hammer.TouchMouseInput }Tested on Chrome and FF for android, Chrome and Safari for iOS and Chrome, FF, Safari and Opera for OSX.@attiks I noticed this disabled swiping with the mouse on desktop view. For folks that need to support horizontal swiping on desktop and mobile devices, can try the following (this is 99% Attiks’ solution, just one minor change on my part, changing TouchInput to TouchMouseInput):
This doesn’t seem to break anything in my project, hopefully it’s kosher. 😃
Just making @FTavukcu’s answer more generic, simply add this:
@josex2r I’ve found a workaround, because I have the same issue as you have. Here it is: