Skip to content

A demonstration to showcase the new View Transitions API for UIX

Notifications You must be signed in to change notification settings

unyt-org/example-view-transitions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

View Transition API

This repository provides a simple UIX setup, to showcase the new View Transitions API.

The View Transitions API provides a mechanism for easily creating animated transitions between different website views. This includes animating between DOM states in a single-page app (SPA), and animating the navigation between documents in a multi-page app (MPA).

example.mp4

Enable View Transitions for UIX

Since the View Transitions API has limited availability still and does only work on Chromium based browsers, the API is not enabled per default for UIX projects. Make sure to include the view-transitions flag to the experimental_features property in your app.dx config file.

experimental_features: ["view-transitions"]

Basic usage

There is a JavaScript API to initiate animations and handle transitions context via document.startViewTransition().

For many usecases it might be enough using the pure CSS solution instead.

You can define a view transition on the element you want to transition from:

.home {
	view-transition-name: my-transition;
}

The following selectors are then available to target the old and new states of the element:

::view-transition-old(my-transition) {
  /* animate out effects */
}

::view-transition-new(my-transition) {
  /* animate in effects */
}

© unyt 2024 • unyt.org

About

A demonstration to showcase the new View Transitions API for UIX

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages