Skip to content

Commit 67c90d8

Browse files
committed
feat: add mayViewTransition utility for improved browser compatibility in view transitions
1 parent 20166c7 commit 67c90d8

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/pages/demo-explainer/BasicS.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,7 @@ To get a smooth transition effect, we run those DOM updates inside `document.sta
5757

5858
To ensure compatibility across different browsers, the script uses a wrapper function called `mayViewTransition`. This wrapper checks if the native view transition API is supported. If it is, `document.startViewTransition` is called; if not, the DOM-changing code is called directly. This approach is a best practice for using `document.startViewTransition`, as it prevents errors in browsers that lack native support for view transitions.
5959

60+
The [Utensil-Drawer package](/tools/utensil-drawer/#maystartviewtransition) provides the `mayViewTransition` function as a convenient utility for this purpose. It is way more elaborated and supports various real-world key challenges.
61+
6062
### View Transition specific CSS
6163
In this example, no specific view transition names are defined. Instead, the example relies on the default view transition name, `root`, which the browser automatically applies to the `<html>` element. This means that the old and new images are those of the viewport before and after the transition and the default effect is a cross-fade between the two images.

0 commit comments

Comments
 (0)