Open dmoli opened 7 years ago
I'm also curious how one would do this for keys (i.e. left key === left swipe; right key === right swipe)
Hi! Do you have any updates on this issue?
I am also interested in doing something like this. Has anyone figured this out?
This has to be done with a ref.
In my example, I put the current swiper into a parent's state using a method I've defined, setCurrentSwiperRef (I use multiple swipers in the same page as people advance)
<Cards
onEnd={() => customOnEnd(props, 1)}
className='master-root'
alertRight={<CustomAlertRight />}
alertLeft={<CustomAlertLeft />}
ref={(instance) => { (typeof props.currentSwiperRef === 'undefined') && props.setCurrentSwiperRef(instance); }}
>
And in some button elsewhere I can do:
<button
onClick={() => { props.currentSwiperRef.removeCard('Left', 0) }}
>
The above utilizes the removeCard method defined here
Hi!
Like/Dislike card with a onSwipeLeft/onSwipeRight currently is ok.
But I want to Like/Dislike card with separate buttons (like a Tinder).
E.g: When I click the "Like Button" I need the card triggers the onSwipeRight. When I click the "Dislike Button" I need the card triggers the onSwipeLeft.
How can I do it?
Could I trigger the onSwipeLeft/onSwipeRight with a click event?
Thanks!