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

Handle touch devices #4

Closed
davidtheclark opened this issue Jan 24, 2016 · 8 comments
Closed

Handle touch devices #4

davidtheclark opened this issue Jan 24, 2016 · 8 comments
Assignees

Comments

@davidtheclark
Copy link

I would like to use this component but need it to handle touch events. This would add some code but increase the value. Essentially, I think we'd need to listen for adapt code from https://github.com/alexgibson/tap.js to listen for touchstart, determine whether the action is a scroll or a "tap", and respond to taps.

Are you open to a PR attempting to implement this?

@kentor kentor self-assigned this Jan 26, 2016
@mech
Copy link

mech commented Jul 25, 2016

This is much needed!

@frontenddeveloping
Copy link

-1

I think developers for major mobile browser vendors don't need touch events since click event can work without delay. To remove the 300-350ms tap delay, all you need is the following in the of your page:

<meta name="viewport" content="width=device-width">

Works fine on Android (stock, chrome, opera, firefox) browsers, iOS 9+

@kentor
Copy link
Owner

kentor commented Aug 3, 2016

Thanks for the info @frontenddeveloping.

My inclination is that mobile user agents should interpret taps as clicks natively which is why I'm hesitant to add a userland implementation for detecting taps. Unfortunately, that doesn't seem to be the case, most of the time.

It turns out that, at least from my testing on mobile safari, the click event won't trigger if the element does not have cursor: pointer. We can add that to <body> (only on touch devices, otherwise that would be ugly) as a temporary work around.

I'm trying to figure out ways to get ios to register taps as clicks without cursor: pointer. If I can't find a better solution then I'll look at implementing tap detection.

@oyeanuj
Copy link

oyeanuj commented Dec 1, 2016

@davidtheclark What solution did you end up with for supporting touch devices?

@kentor Any updates on how you are thinking about this now?

@davidtheclark
Copy link
Author

@kentor
Copy link
Owner

kentor commented Dec 6, 2016

@davidtheclark did you have to update componentDidMount and componentWillUnmount to use teeny-tap?

@davidtheclark
Copy link
Author

@kentor Yeah, that's the idea.

@kentor
Copy link
Owner

kentor commented Dec 13, 2016

Since there isn't really a standard on what a "tap" is and I don't want to be opinionated on what constitutes as a tap, and I don't want to add that code to the library, I'll just add a note on the cursor: pointer on <body> workaround in the README.

basically you can use something like this

if ('ontouchstart' in document.documentElement) {
  document.body.style.cursor = 'pointer';
}

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

No branches or pull requests

5 participants