Suggestion: drop the `vertical` prop and replace it with a `direction` prop
I find the vertical prop somewhat confusing as it does not actually limit Hammer to vertical gestures, but to gestures in all directions.
From the code:
// Hammer.js, L53
if (props.vertical) {
hammer.get('pan').set({direction: Hammer.DIRECTION_ALL});
hammer.get('swipe').set({direction: Hammer.DIRECTION_ALL});
} else {
hammer.get('pan').set({direction: Hammer.DIRECTION_HORIZONTAL});
hammer.get('swipe').set({direction: Hammer.DIRECTION_HORIZONTAL});
}
Given the Hammer.DIRECTION_* constants it'd be better to allow one to use those by means of a direction prop.
Example usage would be this:
var Hammer = require('hammerjs');
var ReactHammer = require('react-hammerjs');
<ReactHammer onSwipe={handleSwipe} direction="{Hammer.DIRECTION_VERTICAL}"><div>Swipe Me</div></ReactHammer>
(note that I also import Hammer itself, to gain access to the contstants. These could - for example - also be exposed on react-hammerjs)
+1
I'm having a hard time implementing this with version 0.5.0 not sure what I'm missing. Do you have a more explicit example with the merged PR? Also the fallback of vertical breaks completely with the error: Uncaught ReferenceError: direction is not defined (I am working with this for onPan)
I get the error Uncaught ReferenceError: direction is not defined when defining direction={...} as well.
@shalanah look at this:
https://github.com/react-component/swipeout/blob/master/src/Swipeout.web.js#L210