@@ -25,6 +25,10 @@ import { ifDefined } from "lit/directives/if-defined";
2525import memoizeOne from "memoize-one" ;
2626import { isComponentLoaded } from "../../common/config/is_component_loaded" ;
2727import { fireEvent } from "../../common/dom/fire_event" ;
28+ import {
29+ applyViewTransitionOnLoad ,
30+ startViewTransition ,
31+ } from "../../common/dom/view_transition" ;
2832import { shouldHandleRequestSelectedEvent } from "../../common/mwc/handle-request-selected-event" ;
2933import { goBack , navigate } from "../../common/navigate" ;
3034import type { LocalizeKeys } from "../../common/translations/localize" ;
@@ -72,7 +76,7 @@ import {
7276} from "../../dialogs/quick-bar/show-dialog-quick-bar" ;
7377import { showShortcutsDialog } from "../../dialogs/shortcuts/show-shortcuts-dialog" ;
7478import { showVoiceCommandDialog } from "../../dialogs/voice-command-dialog/show-ha-voice-command-dialog" ;
75- import { haStyle , haStyleAnimations } from "../../resources/styles" ;
79+ import { haStyle , haStyleViewTransitions } from "../../resources/styles" ;
7680import type { HomeAssistant , PanelInfo } from "../../types" ;
7781import { documentationUrl } from "../../util/documentation-url" ;
7882import { showToast } from "../../util/toast" ;
@@ -623,6 +627,9 @@ class HUIRoot extends LitElement {
623627 window . addEventListener ( "scroll" , this . _handleWindowScroll , {
624628 passive : true ,
625629 } ) ;
630+
631+ // Trigger view transition on initial load
632+ applyViewTransitionOnLoad ( this ) ;
626633 }
627634
628635 public connectedCallback ( ) : void {
@@ -1162,43 +1169,45 @@ class HUIRoot extends LitElement {
11621169 // Recreate a new element to clear the applied themes.
11631170 const root = this . _viewRoot ;
11641171
1165- if ( root . lastChild ) {
1166- root . removeChild ( root . lastChild ) ;
1167- }
1172+ startViewTransition ( ( ) => {
1173+ if ( root . lastChild ) {
1174+ root . removeChild ( root . lastChild ) ;
1175+ }
11681176
1169- if ( viewIndex === "hass-unused-entities" ) {
1170- const unusedEntities = document . createElement ( "hui-unused-entities" ) ;
1171- // Wait for promise to resolve so that the element has been upgraded.
1172- import ( "./editor/unused-entities/hui-unused-entities" ) . then ( ( ) => {
1173- unusedEntities . hass = this . hass ! ;
1174- unusedEntities . lovelace = this . lovelace ! ;
1175- unusedEntities . narrow = this . narrow ;
1176- } ) ;
1177- root . appendChild ( unusedEntities ) ;
1178- return ;
1179- }
1177+ if ( viewIndex === "hass-unused-entities" ) {
1178+ const unusedEntities = document . createElement ( "hui-unused-entities" ) ;
1179+ // Wait for promise to resolve so that the element has been upgraded.
1180+ import ( "./editor/unused-entities/hui-unused-entities" ) . then ( ( ) => {
1181+ unusedEntities . hass = this . hass ! ;
1182+ unusedEntities . lovelace = this . lovelace ! ;
1183+ unusedEntities . narrow = this . narrow ;
1184+ } ) ;
1185+ root . appendChild ( unusedEntities ) ;
1186+ return ;
1187+ }
11801188
1181- let view ;
1182- const viewConfig = this . config . views [ viewIndex ] ;
1189+ let view ;
1190+ const viewConfig = this . config . views [ viewIndex ] ;
11831191
1184- if ( ! viewConfig ) {
1185- this . lovelace ! . setEditMode ( true ) ;
1186- return ;
1187- }
1192+ if ( ! viewConfig ) {
1193+ this . lovelace ! . setEditMode ( true ) ;
1194+ return ;
1195+ }
11881196
1189- if ( ! force && this . _viewCache ! [ viewIndex ] ) {
1190- view = this . _viewCache ! [ viewIndex ] ;
1191- } else {
1192- view = document . createElement ( "hui-view" ) ;
1193- view . index = viewIndex ;
1194- this . _viewCache ! [ viewIndex ] = view ;
1195- }
1197+ if ( ! force && this . _viewCache ! [ viewIndex ] ) {
1198+ view = this . _viewCache ! [ viewIndex ] ;
1199+ } else {
1200+ view = document . createElement ( "hui-view" ) ;
1201+ view . index = viewIndex ;
1202+ this . _viewCache ! [ viewIndex ] = view ;
1203+ }
11961204
1197- view . lovelace = this . lovelace ;
1198- view . hass = this . hass ;
1199- view . narrow = this . narrow ;
1205+ view . lovelace = this . lovelace ;
1206+ view . hass = this . hass ;
1207+ view . narrow = this . narrow ;
12001208
1201- root . appendChild ( view ) ;
1209+ root . appendChild ( view ) ;
1210+ } ) ;
12021211 }
12031212
12041213 private _openShortcutDialog ( ev : Event ) {
@@ -1209,7 +1218,7 @@ class HUIRoot extends LitElement {
12091218 static get styles ( ) : CSSResultGroup {
12101219 return [
12111220 haStyle ,
1212- haStyleAnimations ,
1221+ haStyleViewTransitions ,
12131222 css `
12141223 : host {
12151224 - ms- user- select: none;
@@ -1264,8 +1273,7 @@ class HUIRoot extends LitElement {
12641273 padding : 0px 12px ;
12651274 font-weight : var (--ha-font-weight-normal );
12661275 box-sizing : border-box;
1267- animation : fadeIn var (--ha-animation-duration ) ease-out both;
1268- animation-delay : var (--ha-animation-delay-base );
1276+ view-transition-name : lovelace-toolbar;
12691277 }
12701278 .narrow .toolbar {
12711279 padding : 0 4px ;
@@ -1414,8 +1422,7 @@ class HUIRoot extends LitElement {
14141422 hui-view-container > * {
14151423 flex : 1 1 100% ;
14161424 max-width : 100% ;
1417- animation : fadeInSlideDown var (--ha-animation-duration ) ease-out both;
1418- animation-delay : var (--ha-animation-delay-base );
1425+ view-transition-name : lovelace-view;
14191426 }
14201427 /**
14211428 * In edit mode we have the tab bar on a new line *
0 commit comments