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

Add TapEventPlugin to ReactWithAddons #470

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/docs/09-addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ next: animation.html
- `ReactTransitions`, for dealing with animations and transitions that are usually not simple to implement, such as before a component's removal.
- `ReactLink`, to simplify the coordination between user's form input data and and the component's state.
- `classSet`, for manipulating the DOM `class` string a bit more cleanly.
- Multiple event plugins for handling non-standard (but useful) events.

To get the add-ons, use `react-with-addons.js` (and its minified counterpart) rather than the common `react.js`.
2 changes: 1 addition & 1 deletion docs/docs/09.3-class-name-manipulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Class Name Manipulation
layout: docs
permalink: class-name-manipulation.html
prev: two-way-binding-helpers.html
next: examples.html
next: event-plugins.html
---

`classSet()` is a neat utility for easily manipulating the DOM `class` string.
Expand Down
22 changes: 22 additions & 0 deletions docs/docs/09.4-event-plugins.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
id: event-plugins
title: Event plugins
layout: docs
permalink: event-plugins.html
prev: class-name-manipulation.html
next: examples.html
---

React has a few built-in event plugins to make your life easier.

* `TapEventPlugin` provides an `onTouchTap` event which is similar to the so-called **fast click** event. This looks at raw touch events (`touchstart` `touchmove` and `touchend`) and interprets if the user intended to do a simple tap.
* `ResponderEventPlugin` implements a responder model to negotiate events between multiple components. See [the source code](https://github.com/facebook/react/blob/master/src/eventPlugins/ResponderEventPlugin.js) for more information.

To install these plugins, you need to call `React.addons.injectEventPluginsByName()` like this:

```javascript
React.addons.injectEventPluginsByName({
TapEventPlugin: React.addons.TapEventPlugin,
ResponderEventPlugin: React.addons.ResponderEventPlugin
});
```
7 changes: 7 additions & 0 deletions src/ReactWithAddons.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,22 @@

"use strict";

var EventPluginHub = require('EventPluginHub');
var LinkedStateMixin = require('LinkedStateMixin');
var React = require('React');
var ReactTransitionGroup = require('ReactTransitionGroup');
var ResponderEventPlugin = require('ResponderEventPlugin');
var TapEventPlugin = require('TapEventPlugin');

var cx = require('cx');

React.addons = {
classSet: cx,
injectEventPluginsByName:
EventPluginHub.injection.injectEventPluginsByName,
LinkedStateMixin: LinkedStateMixin,
ResponderEventPlugin: ResponderEventPlugin,
TapEventPlugin: TapEventPlugin,
TransitionGroup: ReactTransitionGroup
};

Expand Down