Re: [csswg-drafts] [css-view-transitions-2] Feature detection for VT cross-document (#9891)

Thanks for bringing this up Suraj. The chromium bug for this feature is [here](https://issues.chromium.org/40211832). Please +1 to bump it on the priority list.

In the meantime, there's a couple of ways that should work.

- In CSS, `:root:active-view-transition` would activate if there is a transition running. You can use it to limit styles which should only apply when there is a transition. You can also use types to limit to navigation specific transitions. For example,

```css
:root:active-view-transition #foo {
   view-transition-name: foo;
}

/* or */

@view-transition {
  navigation: auto;
  types: navigation;
}

:root:active-view-transition(navigation) #foo {
   view-transition-name: foo;
}
```

- In script, `pageswap` and `pagereveal` events are fired when navigating away and to a page respectively. If the event has the `viewTransition` attribute then VT cross-document is supported. For example,

```js
onpageswap = (e) => {
   if (Object.hasOwn(e, 'viewTransition')) {
      ...
   }
}
```

Would these suffice? If not, please let me know the use-case and I'll try to see if there's a better suggestion.

-- 
GitHub Notification of comment by khushalsagar
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9891#issuecomment-2221003864 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 10 July 2024 16:47:02 UTC