From 30659c270bd6270a2f078e5b12a9436cc724202f Mon Sep 17 00:00:00 2001 From: Maurizio Carella Date: Thu, 13 Jun 2019 12:37:29 +0200 Subject: [PATCH 1/3] Added onLongPress callback with isFlipped param --- lib/FlipCard.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/FlipCard.js b/lib/FlipCard.js index 48baeb4..f705fb8 100644 --- a/lib/FlipCard.js +++ b/lib/FlipCard.js @@ -170,6 +170,7 @@ export default class FlipCard extends Component { testID={this.props.testID} activeOpacity={1} onPress={() => { this._toggleCard(); }} + onLongPress={() => {this.props.onLongPress(this.state.isFlipped)}} > {}, onFlipStart: () => {}, + onLongPress: () => {}, alignHeight: false, alignWidth: false, useNativeDriver: true, From 3befaae1889554ad9e9f522a43299f2c816524fb Mon Sep 17 00:00:00 2001 From: Maurizio Carella Date: Thu, 13 Jun 2019 12:43:32 +0200 Subject: [PATCH 2/3] Updated README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 992441d..a15514b 100644 --- a/README.md +++ b/README.md @@ -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. From 0d2301ea2293dc9c7a9ec854a26eda8c15fc6883 Mon Sep 17 00:00:00 2001 From: Maurizio Carella Date: Fri, 14 Jun 2019 17:18:02 +0200 Subject: [PATCH 3/3] Fix infinite loop when using prop flip caused by calling _toggleCard in componentWillReceiveProps --- lib/FlipCard.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/FlipCard.js b/lib/FlipCard.js index f705fb8..431a80e 100644 --- a/lib/FlipCard.js +++ b/lib/FlipCard.js @@ -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 () {