Skip to content

Commit

Permalink
Document shouldRejectClick functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhicks-bsf committed Jul 8, 2015
1 parent 9915966 commit f5139b1
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,32 @@ var Main = React.createClass({
});

React.render(<Main />, document.body);
```
```

### Ignoring ghost clicks

When a tap happens, the browser sends a `touchstart` and `touchend`, and then
300ms later, a `click` event. This plugin ignores the click event if it has
been immediately preceeded by a touch event (within 750ms of the last touch
event).

Occasionally, there may be times when the 750ms threshold is exceeded due to
slow rendering or garbage collection, and this causes the dreaded ghost click.

The 750ms threshold is pretty good, but sometimes you might want to override
that behaviour. You can do this by supplying your own `shouldRejectClick`
function when you inject the plugin.

The following example will simply reject all click events, which you might
want to do if you are always using `onTouchTap` and only building for touch
devices:

```js
var React = require('react'),
injectTapEventPlugin = require("react-tap-event-plugin");
injectTapEventPlugin({
shouldRejectClick: function (lastTouchEventTimestamp, clickEventTimestamp) {
return true;
}
});
```

0 comments on commit f5139b1

Please sign in to comment.