react-pressable
react-pressable is a React component that provides the convenience events
onRelease
, onReleaseOutside
, onReleaseInside
, and onPress
. It works with
any component that supports the normal React mouse events.
Installation
browserify and webpack users can simply npm install react-pressable
.
Bower users can bower install react-pressable
.
You can also just download the react-pressable.js file from the standalone directory in the repository.
Usage
Composition is very easy:
var Pressable = ; var MyComponent = React
However, Pressable also lets you create a pressable version of an existing
component using the from
static method. This is often cleaner and avoids
markup pollution:
var Pressable = ;var PressableSpan = Pressable; var MyComponent = React
Event Types
Name | Description |
---|---|
onPress |
Currently the same as onMouseDown . |
onRelease |
Invoked when the mouse button is released after pressing the component, regardless of where the cursor is. |
onReleaseOutside |
Invoked when the mouse button is released after pressing the component, if the cursor is outside of the component. |
onReleaseInside |
Invoked when the mouse button is released after pressing the component, if the cursor is inside the component. |