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

# Display Text when swipe card like tinder

Open safalpatel-nl opened this issue 7 years ago • 8 comments

Hi ,

I Used this library i want to display text when card swipe like tinder show. Help!!!!!!!!

safalpatel-nl avatar May 30 '18 14:05 safalpatel-nl

have you found any solution for that?

saibendalam avatar Jul 08 '19 11:07 saibendalam

+1 ? any solution?

safciplak avatar Jul 09 '19 15:07 safciplak

anyone?

georgeMorales avatar Feb 05 '20 17:02 georgeMorales

I managed to recreate the tinder effect by adding in animated views for the text inside of the CardStack.js's render() function where it creates the 2 animated views for the two visible cards.

Example for cardB: <Animated.View {...this._setPointerEvents(topCard, 'cardB')} style={{//...styles}}> {cardB} {(topCard === 'cardB') ? likeLabel : null} {(topCard === 'cardB') ? nopeLabel : null}

And here's a text label component example: const likeLabel = <Animated.View style={{ transform: [{ rotate: "-22.5deg" }], opacity: likeOpacity, position: "absolute", top: '10%', left: '10%', zIndex: 1000 }} > <Text style={{ backgroundColor: 'dodgerblue', color: "white", fontSize: 48, fontWeight: "200", paddingHorizontal: 10, paddingVertical: 5, borderRadius: 15, overflow: 'hidden', }} >Y E S</Text> </Animated.View>

Here's how I'm setting the opacity: const likeOpacity = drag.x.interpolate({ inputRange: [-width / 3, width * .025, width / 3], outputRange: [0, 0, 1], extrapolate: 'clamp', });

This is all inside of the render() function, hope it helps!

joego2124 avatar Feb 11 '20 22:02 joego2124

And put a cardIndex props? It would be very good to be able to control the index...

georgeMorales avatar Feb 12 '20 09:02 georgeMorales

I'm pretty sure that CardStack keeps track of the index internally (same index as the array of child card components), you can create additional wrapper functions around the existing functions (goBack, etc) to jump to a card with a specific index.

joego2124 avatar Feb 12 '20 15:02 joego2124

@joego2124 True, I've been testing this morning, sindex is one of them ... Thank you!

georgeMorales avatar Feb 12 '20 16:02 georgeMorales

I managed to recreate the tinder effect by adding in animated views for the text inside of the CardStack.js's render() function where it creates the 2 animated views for the two visible cards.

Example for cardB: <Animated.View {...this._setPointerEvents(topCard, 'cardB')} style={{//...styles}}> {cardB} {(topCard === 'cardB') ? likeLabel : null} {(topCard === 'cardB') ? nopeLabel : null}

And here's a text label component example: const likeLabel = <Animated.View style={{ transform: [{ rotate: "-22.5deg" }], opacity: likeOpacity, position: "absolute", top: '10%', left: '10%', zIndex: 1000 }} > <Text style={{ backgroundColor: 'dodgerblue', color: "white", fontSize: 48, fontWeight: "200", paddingHorizontal: 10, paddingVertical: 5, borderRadius: 15, overflow: 'hidden', }} >Y E S</Text> </Animated.View>

Here's how I'm setting the opacity: const likeOpacity = drag.x.interpolate({ inputRange: [-width / 3, width * .025, width / 3], outputRange: [0, 0, 1], extrapolate: 'clamp', });

This is all inside of the render() function, hope it helps!

have one code link, i am newbie.. i am trying too... thx

denisonfer avatar Jun 08 '20 22:06 denisonfer