diff --git a/lib/FlipCard.js b/lib/FlipCard.js index 21cbd5f..4838280 100644 --- a/lib/FlipCard.js +++ b/lib/FlipCard.js @@ -40,13 +40,14 @@ export default class FlipCard extends Component { this.props.onFlipStart(this.state.isFlipped) this._animation(!this.state.isFlipped) } - _animation (isFlipped) { + _animation (isFlipped) { if (!this.timer) { this.timer = setTimeout(() => { this.setState({isFlipped: !this.state.isFlipped}) this.timer = null }, 120) } + Animated.spring(this.state.rotate, { toValue: Number(isFlipped), @@ -77,6 +78,14 @@ export default class FlipCard extends Component { }) } + _onPress() { + if (this.props.shouldFlipOnUserTap) { + this._toggleCard() + } else { + this.props.onPress() + } + } + render () { var c = this.props.children; var transform = this.props.perspective ? [{ perspective: this.props.perspective }] : [] @@ -162,8 +171,8 @@ export default class FlipCard extends Component { return ( { this._toggleCard(); }} + activeOpacity={ this.props.activeOpacity } + onPress={ this._onPress.bind(this) } > {} } @@ -295,4 +310,4 @@ Back.propTypes = { perspective: PropTypes.number, children (props, propName, componentName) { } -} +} \ No newline at end of file