-
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
Pan event doesn't work correctly with touch-action pan-y in Chrome 55 #1050
Comments
I have a similar problem - panmove has been working for nearly 2 years, no change to the code and it's stopped. This is Chromium Version 55.0.2883.75 (64-bit). The event appears to trigger correctly at first but the event data I am capturing (var x = event.changedPointers[0].movementX * -1;var y = event.changedPointers[0].movementY * -1;) appears as 0 values. The event will then trigger with any mouse move (not pan) over the bound area. It appears to work fine in Firefox 50.0.2 but there my bound Tap events are now passing incorrect x/y info. |
I think i too am having this issue after updating to Chrome to Version 55.0.2883.75. All pan directions are a problem for me right now. PanStart fires as expected, but the onPan event fires once only, for that entire gesture. *Note, it only seems to be a problem while touch emulation is running. If you disable "touch emulation" then everything works as expected. My guess is the chrome team changed something in the way that chrome emulates device touch events... |
+1 , I have the same problem on pandown/panup and my panend is never triggered . |
+1 This is a very big problem =(( |
Agreed - I'm going to have to pull hammer out of my project if it remains this way. |
Ok, I'm not crazy ^^ I have exactly the same problem. |
looks like chrome team indeed update touch-action options. they added 'pan-up pan-down pan-left pan-right' with earlier pan-x and pan-y. they might be interfering with the TOUCH_ACTION constants in hammer.
This line could be the troubling bit. cc:- @arschmitz |
So we're also in the unfortunate predicament of being very, very close to a launch. The app concerned is pretty heavily affected by this bug. Is there any chance at all, we could get some kind of eta on a potential patch? Or even just an indication of how severe this problem really is (and how complicated the fix will need to be) - would be awesome. I really don't want to have to rip hammer out of the project (hammer rox!) - but may be forced to if this issue remains for much longer. :( |
@glomotion Chrome Dev for Android have the problem too , not only emulator |
@zuibunan Yup. I'm now finding that too. :( I think it was because the Android devices I was testing on were yet to upgrade to Chrome 55. 55 appears to have since rolled out to all our test devices now - and now they all show this problem. |
Any one able to find a solution for this problem? |
Make sure you set the proper touch-action css attribute for your canvas element. |
I've done some digging and testing and it looks like the Chrome's new Pointer Events api has some issues:
That last thing might be the problem if you, like me, attached hammer to an element that has children because the event gets cancelled if you start the touch on a child element (it fires pointerdown, pointermove and then pointercancel). I've created tickets for the issues above on the chromium tracker so you can star those: |
As an addition to @gargsahil25 solution: make sure the touch-action property is set to all child elements as well: I recommend not using the Also, using (PS: the above solution is a complete hack/workaround for a bug. the bug needs fixing, this solution needs to go :P) |
Thanks @gargsahil25, it worked semi-ok. I have a couple of carousels on the mobile website and this at least made it pan i y-direction as it did before. The only problem is that before Chrome 55 rolled out, I could put my finger on the carousel and scroll up and down on the page, whereas now nothing happens. Maybe that can be solved with hammer.js itself. If anyone have a clue about how to fix that, I'm listening. |
@antipod You want horizontal carousel but have vertical scroll work? See hammerjs docs: And: |
@rejhgadellaa I did try that but it doesn't work completely. I can pan in the x direction, and it will allow me to scroll on the page. BUT, hammer.js registers that vertical scroll as a panleft / panright on the carousel and it bugs like it did before, after Chrome updated to 55. Though it only registers it once. Still, this offsets the carousel. Might be a solution there somewhere... I'll find it. |
@antipod did you also attach |
I'm afraid that touch-action on my affected elements didn't solve any of them so sadly it appears to be an incomplete hack. |
cc @arschmitz I think this is a little out of my knowledge domain at the moment, if there's a new spec to read I'll read it and a link to new APIs is appreciated but sounds like this may also require some spelunking on how the new stuff works? |
When I use v2.04 or the latest version v2.08 Nov, this doesn't allow me to pan or swipe in Chrome 55. However, with v2.08 Apr, distributed version irons out all the bugs I got. So someone like me should use the distributed version first before trying anything else. Oops, actually without "touch-action: none", it doesn't work in the Chrome debugging mode (touch emulation). So, you should use both the distributed version v2.08 Apr and touch-action: none. |
Again, using the Apr distributed version (I'm assuming by that you mean the .min.js file) === no dice (I was using that version all along). Noting that the Hammer home page works fine and demos the functionality that I previously had working with panmove, I had a look at the code. I see there that you use the event.deltaX/Y values where I had been using the event.changedPointers[0].movementX/Y values. However adapting my code to use these did not result in a fix as e.g. changing direction mid-pan is not reflected by these values (as they are deltas). @runspired & @arschmitz I really apologise for telling you guys what to do, but it strikes me that if the developers of the world's most popular browser decide to alter their internal API and that impinges directly on your maintained project's functionality, then you're going to have to bite the bullet and re-factor. Or be maintainers of an increasingly out-of-date project. |
And if it's any consolation (and I know it isn't) I've had Google do this to me on multiple occasions also :( |
@BossLevel Can you adapt your code something like this? In firefox, two values are the same most of the time except outside the boundaries. Here is my pen http://codepen.io/hanwiz/pen/ObqGEo.
|
@hanwiz - thanks for your time and effort - the good news is that with some slight modifications, your code works :) 2 points to make before documenting said modifications:
With that in mind, line 14 of your pen can be reduced to In addition, after ending a panmove, the next pan jerks initially. To remove this add the additional following binding:
I still think something needs to be done about this issue (or at least have an example/documentation on the site) but that's your business and I once again thank you for your efforts, particularly @hanwiz |
Adding the "touch-action: pan-y" to the affected scrollable element (and it's descendants) solved the issue for me. Here's the SASS class that I used:
|
So I'm still having quite a few problems with Hammer. |
One of the Chromium tickets mentioned above has been fixed Would it fix this issue or the Hammer team should still make a fix? |
@Mathews2115 has your workaround been behaving well? Would it be hard to do this in hammerjs itself? I don't understand how the bogus event comes to be, for me it only happens when I pan across a certain area of my screen… |
@wmertens So far so good on my end. |
fixed with the same |
@glomotion Thank you very much, it works correctly when i do it as you said. |
@blackswanny - I think I'm seeing similar behavior where many of the pans aren't being recognized right on Android, I made a project to reproduce the issue and #1118 as a simple fix that improves the case I'm running into at least |
Got the same issue yesterday during the work with Hammer.js. Here is the solution:
|
same problem here. |
@web-jenezis : your solution worked for me. I saw that the |
@web-jenezis @malina-kirn I used Hammer for React and not sure that directions prop is passed to hammer, cause i still see issues with it
|
@blackswanny : as @web-jenezis pointed out, setting the CSS:
Add the |
add: |
@garyskiba easier solution if you add the var SUPPORT_POINTER_EVENTS = false; line at the beginning of your file. It's dirty but at least don't touch the hammer.js itself |
@fssrepository , according to what i see it's not global var and we can't override it so hammer will pick up another value. But I would rather change this var than override native PointerEvent, cause not like to affect other parts of app |
@garyskiba @fssrepository Both solutions brakes 'press' if u are unfornate as me if u want to use both 'pan' and 'press' with hammerJS globally available |
Chrome > 55 implements pointer events but in order for them to work properly we need to make sure that all children of swipe element have touch-action property (it is not inherited in chrome) see: hammerjs/hammer.js#1050
The actual issue described still persists today - not surprising since hammerjs hasn't been updated. That is the issue of getting wildly odd numbers like deltaX: -120 As others have mentioned, the solution is to use I had cases where I wanted to be informed about the attempt of the user to scroll - i didn't really need a delta. I just needed to know which direction it was. Turns out you can filter out these bizarre numbers with:
That leaves you with a few events like Remember that when you scroll the whole page what do you really expect delta to be? You're moving the whole viewport after all! This at least filters out that awful janky large seemingly random numbers.
|
On the parent wrapper: The element inside the wrapper I wanted to be able to scroll vertically: Solved it for me! |
I have tried if (ev.eventType !== Hammer.INPUT_MOVE) return; in my handler. this saves me from the trouble. |
Thanks @divisey That combo works fine to me:
|
I was also getting a lot of premature Adding the |
Before upgrade to Chrome 55.0.2883.59 beta (64-bit), it works fine
but now, when I pulldown in chrome emulator , the panmove event just triggered once or twice, and the event data is not correct
this is the right event data when i set touchAction none, but if touchAction is none , the page will not scroll
coarse demo
http://jsbin.com/tevitozuku/edit?output
The text was updated successfully, but these errors were encountered: