Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

198
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda