react-native-card-stack-swiper icon indicating copy to clipboard operation
react-native-card-stack-swiper copied to clipboard

this.swiper.goBackFrom[left/right/top/bottom] doesn't put last card back on top of stack

Open marvinkennis opened this issue 6 years ago • 1 comments

Whenever I swipe a card, then use the goBackFrom...() function, it doesn't put the last swiped card on top. Instead, it puts the card that is at the bottom of the stack on top. Any fixes? Cheers!

marvinkennis avatar Jul 19 '18 04:07 marvinkennis

Try replace componentWillReceiveProps function in CardStack.js with following

componentWillReceiveProps(nextProps){ if (!this._isSameChildren(nextProps.children, this.props.children)) { this.setState({ cards: nextProps.children, cardA: nextProps.children[(this.state.topCard=='cardA')? this.state.sindex-2 : this.state.sindex-1], cardB: nextProps.children[(this.state.topCard=='cardB')? this.state.sindex-2 : this.state.sindex-1] }); } }

then add the comparison function

_isSameChildren(a, b) { if (a.length != b.length) return false; for (let i in a) { if (a[i].key != b[i].key) { return false } } return true }

blin0129 avatar Mar 05 '19 01:03 blin0129