#how to create responsive swipe cards
27 messages · Page 1 of 1 (latest)
can you explain a little bit more about what you mean by "swipe card"
like this card slider
yes, with react passing data from json file
ok so you're using React, not vanilla JS?
ok basically, you need to take your array of all cards and slice it to a new array that only includes the ones visible at the moment
okay
const visible = cards.slice(i, i + 3)
then you map over these and render them
plus some buttons that just increment and decrement i
i can just use media query for grid and use 1fr
ok but you only need to show some of the cards at once
for mobile I want touch functionality
you can't show all the cards at once
there's JS touch events for swipes IIRC, never worked with them before
I probably should have mentioned using a package first
It’s a better idea than making your own if you’re looking to make a real product, but if you’re just trying to learn react then I’d suggest implementing it yourself
It doesn’t seem like you’re very far along in learning React, so building it yourself will help you get a little more practice