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

Prevent onPanStart from being fired from pointercancel event #1118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Prevent onPanStart from being fired from pointercancel event #1118

wants to merge 1 commit into from

Conversation

MattKunze
Copy link

@MattKunze MattKunze commented Jun 22, 2017

This improves behavior on Android associated with #1050. This is reproducible when panning content that also scrolls vertically - if you scroll the content hammer is firing a spurious onPanStart event, and the state machine gets messed up for subsequent pan events until you scroll horizontally again.

I've created a simple test application that demonstrates the problem: https://github.com/MattKunze/swipe-handler

You can reproduce the behavior in Chrome by simulating a device. The following video shows the behavior - the first swipe works because the scroll position isn't changed, after scrolling vertically you see the incorrect onPanStart event, and panning doesn't work until it resets after the stream of touch events ends, then you can repeat the process:

video

Note that I'm still needing to reject events where ev.srcEvent.type === 'pointercancel', but this is needed to fix the behavior where a lot of pans aren't recognized on Android in the first place

@renatorib
Copy link

renatorib commented Jul 11, 2017

Nice!
I had several problems with this, which I fixed with a check.

if (event.srcEvent.type !== 'pointercancel') { /* my pan handling */ }

@MattKunze
Copy link
Author

We've actually found that correctly setting the touch-action CSS property avoids the issue for the most part on Android, making this unnecessary. I'll post an update once I have some time that explains what is working for us

@wmertens
Copy link

wmertens commented Dec 7, 2017

@MattKunze so, did you find a good way to make this work?

@MattKunze
Copy link
Author

Yeah, setting touch-action: pan-y in the style for the container seems to avoid the pointer events that are causing the issue in the first place. I haven't had time to revisit the example I posted above to see what is the minimal update that gets it work

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.

None yet

3 participants