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

Components should be able to listen to tap events #436

Closed
petehunt opened this issue Oct 18, 2013 · 18 comments
Closed

Components should be able to listen to tap events #436

petehunt opened this issue Oct 18, 2013 · 18 comments

Comments

@petehunt
Copy link
Contributor

Question: how do you use touch events with React?

Answer:

  • Use CommonJS
  • git clone
  • edit ReactDefaultInjection.js to include TapEventPlugin
  • npm install; grunt
  • add React.initializeTouchEvents(true) to your code in the right place

This sucks. Instead I think we should just either put TapEventPlugin on addons or create a react-mobile build which does all this by default.

@shauntrennery
Copy link
Contributor

+1 for a react-mobile build

@bloodyowl
Copy link
Contributor

👍 for the add-on

@appsforartists
Copy link

In the meantime, you can do this:

require('react/lib/EventPluginHub').injection.injectEventPluginsByName({
"ResponderEventPlugin": require('react-touch/lib/thirdparty/ResponderEventPlugin'),
"TapEventPlugin": require('react-touch/lib/thirdparty/TapEventPlugin')
});

React.initializeTouchEvents(true);

(I just copied this from react-touch-lib and pointed the require statements at the right files).


Edit: Better yet, just use injectTapEventPlugin.

@revolunet
Copy link

+1

@sophiebits sophiebits changed the title TapEventPlugin should be available Components should be able to listen to tap events Sep 3, 2015
@b0c1
Copy link

b0c1 commented Oct 29, 2015

please put the TapEventPlugin to the addons (exists in react-addons package) because we want to use Material-UI without nodejs build (we want to use scala js) but we can't compile the TapEventPlugin as standalone (if you compile it will include the react core)...

@d4rky-pl
Copy link
Contributor

+1 on comment above, I'm trying to use it without full nodejs stack and it's next to impossible to do without manual rewriting

@jimfb
Copy link
Contributor

jimfb commented Feb 2, 2016

Tap is not a standard event, so we're probably going to rip it out of the core and let people detect taps in user land. The current implementation probably needs a bit of cleanup anyway, to detect things like double taps and long holds.

Anyway, it's only 100 lines of code, available here:
https://github.com/facebook/react/blob/bef45b0b1a98ea9b472ba664d955a039cf2f8068/src/renderers/dom/client/eventPlugins/TapEventPlugin.js

If someone wants to fix it up and publish it as an external library/module, that might be useful to people.

@revolunet
Copy link

@MoOx
Copy link

MoOx commented Feb 2, 2016

@revolunet this works like a charm for me. It only handle simple tap. Double tap and long tap needs to be "calculated" by hand from this plugin.

@antoinerousseau
Copy link

Any update on this? should we make use of the add-on or keep using https://github.com/zilverline/react-tap-event-plugin (once it's fixed for v15.0)?

@sophiebits
Copy link
Contributor

We don't have any supported solution for this. In general we don't support defining custom event types for the same reason we don't have any global configuration: because it makes interoperability difficult (if you develop a component that requires TapEventPlugin, it won't work for someone who doesn't load it).

My best recommendation if you need this is to build a <Tappable onTap={}> component or similar completely in user space without depending on React internals. It should also be possible to fix up react-tap-event-plugin for v15, but we don't support that and can't guarantee that it will still work in a future release.

@antoinerousseau
Copy link

Thanks @spicyj for your quick update on this

@antoinerousseau
Copy link

Seems that react-tap-event-plugin recently got fixed for React v15 on their master branch. Just tried it and seems to work well again with material-ui. Won't be long before it reaches NPM.

zilverline#65

@0xMarkian
Copy link

0xMarkian commented Aug 23, 2016

Hi guys.
Update about react-tap-event-plugin: We may probably don't need to use it now.

As posted #6221(comment)

For some reason, I remembered touch events not being detected without TapEventPlugin being installed. I just tested it, and that is no longer the case. Since Chrome and Safari have both removed their tap delays for mobile pages, it's probably time to stop using TapEventPlugin and just us the onClick event.

@shishirarora3
Copy link

Hi,

I was using fastClick.js for touch based devices. Is it no more needed with react?

Regards’
Shishir Arora

On 23-Aug-2016, at 9:25 PM, Markian Ivanicho notifications@github.com wrote:

Hi guys.
Update about react-tap-event-plugin: We may probably don't need to use it now.

As posted here #6221 (comment)
For some reason, I remembered touch events not being detected without TapEventPlugin being installed. I just tested it, and that is no longer the case. Since Chrome and Safari have both removed their tap delays for mobile pages, it's probably time to stop using TapEventPlugin and just us the onClick event.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub #436 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/AIKvJrPnBqLjdcL8hpsIb5_3pzbOhmrhks5qixfrgaJpZM4BHEoN.

@dickeylth
Copy link

dickeylth commented Aug 24, 2016

@markwain For many popular apps that relying on webview to show web pages in China, such as Weixin, Taobao, Alipay, they are still using the old UIWebView in iOS, which still has no love for removing tap delays for mobile pages, so the tap event is still necessary for several years...

@deepfriedbrain
Copy link

And I would think that older mobile devices that cannot be updated to the latest versions of Chrome/Safari would also need the plugin.

ockham added a commit to Automattic/wp-calypso that referenced this issue Aug 29, 2016
ockham added a commit to Automattic/wp-calypso that referenced this issue Oct 7, 2016
ockham added a commit to Automattic/wp-calypso that referenced this issue Dec 3, 2016
ockham added a commit to Automattic/wp-calypso that referenced this issue Dec 13, 2016
ockham added a commit to Automattic/wp-calypso that referenced this issue Jan 11, 2017
ockham added a commit to Automattic/wp-calypso that referenced this issue Jan 16, 2017
ockham added a commit to Automattic/wp-calypso that referenced this issue Jan 16, 2017
facebook/react#436 (comment) indicates that it's no longer needed.

* Remove react-tap-event-plugin from tests
* Accordion: Use onClick instead of onTouchTap
* Accordion Tests: Use Enzyme to simulate click
* SectionNav: Use onClick instead of onTouchTap
* Components: Replace more onTouchTap instances with onClick
* Blocks: Replace more onTouchTap instances with onClick
* DailyPost[Button]: Fix tests
* Accordion Tests: Simplify some more
* docs/react-component-unit-testing.md: Update interaction simulation example
* Site Block: Drop old onClick prop, rename onTouchTap to onClick
 And modify all consumers to no longer rely on the old onClick prop.
juanecabellob added a commit to juanecabellob/generator-jhipster-react that referenced this issue Feb 21, 2017
@gaearon
Copy link
Collaborator

gaearon commented Nov 28, 2017

I started a new thread to discuss how we can move the ecosystem to stop depending on react-tap-event-plugin. It will break for good eventually.

As @sophiebits suggested, it sounds reasonable if folks who depend on it create a userland <Tapable> component instead, and others can depend on it. Let’s discuss this effort in #11689.

@facebook facebook locked and limited conversation to collaborators Nov 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests