Animate out

out plays before a component is removed. The row stays on the page until its animation ends, then leaves:

out: {
  from: { opacity: 1, transform: 'translateX(0)' },
  to: { opacity: 0, transform: 'translateX(32px)' },
  duration: 220,
  easing: 'ease-in',
},

An out animation in a list needs keys. A keyed list knows which row is leaving and patches the others around it while it plays; an unkeyed one can only match rows by position, so the survivors could end up in the wrong places. Playlist.pzl keys each row with key={ album.id }, and a list of store records keys itself by id anyway.

If the page navigates away mid-animation, Puzzle cancels it and carries on at once. Nothing waits on a half-played exit.

Your turn

  1. Add out beside in in PlaylistRow.pzl: fade to opacity: 0 while sliding right with translateX.
  2. Click Remove on a row. It slides away, then the rows below close the gap.

Chapters