Route transitions
Views take the same animations field, and the router plays it when it swaps pages. When you follow a link, the new page's data() runs first. Then the old view plays its out, and the new one renders and plays its in:
// Playlist.pzl
animations = {
in: {
from: { opacity: 0, transform: 'translateY(8px)' },
to: { opacity: 1, transform: 'translateY(0)' },
duration: 300,
easing: 'ease-out',
},
out: {
from: { opacity: 1 },
to: { opacity: 0 },
duration: 160,
easing: 'ease-in',
},
};
One element animates per navigation. The shop and the playlist share the Default layout, so the layout stays put and only the view inside it fades. Keep a view's out short: the next page waits for it.
Your turn
- Add
animationswith aninand anouttoPlaylistViewinPlaylist.pzl. - Click Your playlist in the preview's header, then Shop. The playlist fades in, its rows rise with it, and it fades out on the way back.