Right now we need to swipe to "ignore" current card and view next card.
I was wondering if we can implement a GoToNextCard()?
Usage would be similar to swipeBack() and jumpToCardIndex() but it does not require any parameters. Then it jumps to the next card:
<Swiper ref={ (swiper) => { this._swiper = swiper }}
<Button onPress={() => {this._swiper.GoToNextCard()}} title="Ignore current card"/>
</Swiper>
Right now I am trying this ugly approach where if jumpToCardIndex() takes no parameters I want to go to next card. But it is not working:
jumpToCardIndex = newCardIndex => {
if(newCardIndex === undefined) // if I did not pass parameters
{
this.setState(
{
firstCardIndex: this.state.firstCardIndex + 1, // increment
secondCardIndex: this.calculateSecondCardIndex(this.state.firstCardIndex + 1),
previousCardIndex: this.calculatePreviousCardIndex(this.state.firstCardIndex + 1),
swipedAllCards: swipedAllCards,
panResponderLocked: false
},
this.resetPanAndScale
);
}
else
{
if (this.props.cards[newCardIndex])
{
this.setCardIndex(newCardIndex, false);
}
}
};
And it would be perfect if it gets "ignored" on a button click with exact animation when swiping it! (Not just flickers, it actually moves to a direction and then disappears)
Beautiful work guys and thanks!
This works but crashes when skipping last card:
jumpToCardIndex = newCardIndex => {
if(newCardIndex) // if there was a parameter
{
if (this.props.cards[newCardIndex]) {
this.setCardIndex(newCardIndex, false);}
}
else
{
// else just incremenet
this.incrementCardIndex()
}
};
+1
I have added this feature in 1.2.7.
New methods available :
swipeLeft, swipeRight, swipeTop, swipeBottom
Thanks
Most helpful comment
I have added this feature in 1.2.7.
New methods available :
swipeLeft, swipeRight, swipeTop, swipeBottom
Thanks