Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
How can I create a Tinder-like card stack swiper in React?

I want to create a card swiper and I tried out a few packages already, but none of them were decent and customizable enough, so I considered creating something on my own.

What approach should I go with to create animations, draggable card and a stack of cards, (a new card should be added to the bottom on every swipe)?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

This is a rough idea, but it might work.

I would suggest creating a CardComponent and have them stack on each other, with the last one at the bottom.

return (
   <div className="card-container">
       {
            this.state.cards.map((card, index)=>{
                 return (<CardComponent key={card.id} details={card}></CardComponent>)
            })
       }
   </div>

)

Something like that.

Then in the CSS part, set .card-container to be a holder, and then use the order of the elements of CardComponent which would return <div>stuff here</div>.

Then set .CardComponent > div to position things absolute and then take advantage of the z-index property.

Use this code for whenever you want to remove the first card and append a new card to the end (at the bottom of the card stack).

var count = 0;
// Reverse the array, so you can order from bottom to front
$('.card-container > div').reverse().each(
    function() {
        $(this).css('z-index', ++count);
    }
);

Then you can update the cards state.

let newCardList = this.state.slice(1);
let newCard = null; // Add the new card here
newCardList.append(newCard);
this.setState({
    ...this.state,
     cards: newCardList
})

So on the swipe event on said CardComponent, just get the key from the event, play a slide animation using jQuery, and after the animation ends, just slice the cards array like in the above code.

Also you will need to call this, after you slice, and add a new card.

$('.card-container > div').reverse().each(

about 4 years ago · Juan Pablo Isaza Report

0

I'm assuming you work on a web browser app mainly for computer users.

  • for animations you can just decompose the move in a couple frames,
  • for the swipe you can go with custom event functions if you can't find anything existing,
  • the stack of card is a simple state management and I recommend using hooks.
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!