skipperlla / rn-tinder-card Goto Github PK
View Code? Open in Web Editor NEW⚡ Lightning fast and customizable tinder-like swipe card for React Native
Home Page: https://www.npmjs.com/package/rn-tinder-card
License: MIT License
⚡ Lightning fast and customizable tinder-like swipe card for React Native
Home Page: https://www.npmjs.com/package/rn-tinder-card
License: MIT License
Hello. I tried following the example in the repo . I used useState to store data and changed onSwipedRight and onSwipedLeft callbacks to update the state. The view gets re-rendered but it's empty
Here's my code
export default function App() {
const [data,setData] = React.useState( [
'https://images.unsplash.com/photo-1681896616404-6568bf13b022?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1335&q=80',
'https://images.unsplash.com/photo-1681871197336-0250ed2fe23d?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1287&q=80',
])
const loadData = (index) => {
if(index == 0) {
console.log("loading data")
setData([
'https://images.unsplash.com/photo-1681238091934-10fbb34b497a?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1282&q=80',
])
}
}
return (
<View style={{ flexDirection: "column", display: "flex", flex: 1, backgroundColor: "#14110f" }} >
<GestureHandlerRootView style={styles.wrapper} >
{data.map((item, index) => {
console.log(item)
return (
<View
style={styles.cardContainer}
pointerEvents="box-none"
key={index}
>
<TinderCard
cardWidth={338}
cardHeight={600}
cardStyle={styles.card}
onSwipedRight={() => {
loadData(index)
}}
onSwipedLeft={() => {
loadData(index)
}}
>
<ImageBackground source={{ uri: item }} style={styles.image} >
<View style={{ position: 'absolute',height:"100%",width:"100%", justifyContent:'flex-end', alignItems: 'center',paddingBottom:20, backgroundColor: 'rgba(0,0,0, 0.40)' }}>
<Text>Title goes here</Text>
</View>
</ImageBackground>
</TinderCard>
</View>
);
})}
</GestureHandlerRootView>
</View>
);
}
I have ommited the imports and styling as that's unrelated to the issue.
Feature request
Our users don't instinctively understand that the the cards can be swiped upon app launch. Could we implement a sort of "demo" card swipe animation for the component, indicating the swipe gesture?
Thanks for awesome library.
I just ran your example and run it on web npx expo start --web
.
However, the card item still appears after swiping down, and it makes the parent height change.
Im trying to identify a way to cycle through all the items and then to cycle back to the beginning. Im happy to make the change and PR it in but cant quite work out where to start with it
It would be really nice if we could configure this (current behaviour is too fast/too snappy I think):
const userConfig = {
damping: 15,
stiffness: 120,
mass: 0.5,
overshootClamping: false,
restDisplacementThreshold: 0.001,
restSpeedThreshold: 0.001,
};
BTW great library, thanks for making it!
Hi there!
I am wondering how capturing events of children currently possibly or how to improve. Maybe possible with these steps below, but not otherwise?
PanGestureHandler
(to use that ref in children's simultaneousHandlers
)simultaneousHandlers
of the used PanGestureHandler
@Skipperlla WDYT?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.