WICG/view-transitions

Creating different transitions depending on incoming/outgoing, and back/forward

Closed this issue · 2 comments

One thing I found tricky when creating https://http203-playlist.netlify.app/ was changing the animation depending on the presence of outgoing/incoming components. For example, when animating this sidebar:

Screen Shot 2022-05-20 at 14 06 03

When the sidebar is incoming, I want it to slide in from the right. When it's outgoing, I want it to slide out to the right. When it's neither outgoing or incoming, I'm happy with the default transition.

I achieved this by adding classes to the HTML element signaling the page type of the to & from pages, and from that I could infer if the sidebar was incoming/outgoing/neither. But this feels like a hack.

I thought something like ::page-transition-incoming-image(sidebar):only-child would work, but that doesn't appear to be the case. https://static-misc-3.glitch.me/page-transitions/has/

I also tried various things with :has, but couldn't get it to work.

Solved by adding :only-child