Skip to content
Open
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ onFlipEnd(function) `(isFlipEnd) => {}`
---
When a card finishes a flip animation, call `onFlipEnd` function with param.

onLongPress(function) `(isFlipped) => {}`
---
When a card is long pressed, call `onLongPress` function with param if card is flipped.

alignHeight(boolean) `Default:false`
---
If you pass `true` to `alignHeight` param, the card keep height of bigger side.
Expand Down
6 changes: 5 additions & 1 deletion lib/FlipCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export default class FlipCard extends Component {
}
componentWillReceiveProps (nextProps) {
if (this.state.isFlipped !== nextProps.flip) {
this._toggleCard()
this.setState({isFlipping: true});
this._animation(nextProps.flip);
}
}
_toggleCard () {
Expand Down Expand Up @@ -170,6 +171,7 @@ export default class FlipCard extends Component {
testID={this.props.testID}
activeOpacity={1}
onPress={() => { this._toggleCard(); }}
onLongPress={() => {this.props.onLongPress(this.state.isFlipped)}}
>
<Animated.View
{...this.props}
Expand Down Expand Up @@ -210,6 +212,7 @@ FlipCard.propTypes = {
clickable: PropTypes.bool,
onFlipEnd: PropTypes.func,
onFlipStart: PropTypes.func,
onLongPress: PropTypes.func,
alignHeight: PropTypes.bool,
alignWidth: PropTypes.bool,
useNativeDriver: PropTypes.bool,
Expand All @@ -235,6 +238,7 @@ FlipCard.defaultProps = {
clickable: true,
onFlipEnd: () => {},
onFlipStart: () => {},
onLongPress: () => {},
alignHeight: false,
alignWidth: false,
useNativeDriver: true,
Expand Down