mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-10 11:30:01 +00:00
Fix
This commit is contained in:
@@ -12,22 +12,17 @@ export const ViewTransitionMixin = <T extends Constructor<LitElement>>(
|
|||||||
* @returns Promise that resolves when the transition is complete
|
* @returns Promise that resolves when the transition is complete
|
||||||
*/
|
*/
|
||||||
protected async startViewTransition(
|
protected async startViewTransition(
|
||||||
updateCallback: () => void | Promise<void>,
|
updateCallback: () => void | Promise<void>
|
||||||
transitionName?: string
|
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (
|
if (
|
||||||
!document.startViewTransition ||
|
!document.startViewTransition ||
|
||||||
window.matchMedia("(prefers-reduced-motion: reduce)").matches
|
window.matchMedia("(prefers-reduced-motion: reduce)").matches
|
||||||
) {
|
) {
|
||||||
// Fallback: run the update without a transition
|
// Fallback: update without view transition
|
||||||
await updateCallback();
|
await updateCallback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transitionName) {
|
|
||||||
this.dataset.viewTransition = transitionName;
|
|
||||||
}
|
|
||||||
|
|
||||||
const transition = document.startViewTransition(async () => {
|
const transition = document.startViewTransition(async () => {
|
||||||
await updateCallback();
|
await updateCallback();
|
||||||
});
|
});
|
||||||
@@ -35,12 +30,7 @@ export const ViewTransitionMixin = <T extends Constructor<LitElement>>(
|
|||||||
try {
|
try {
|
||||||
await transition.finished;
|
await transition.finished;
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
// Transitions can be skipped
|
// View transition skipped
|
||||||
} finally {
|
|
||||||
// Clean up transition name if provided
|
|
||||||
if (transitionName) {
|
|
||||||
delete this.dataset.viewTransition;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -500,7 +500,7 @@ class HUIRoot extends ViewTransitionMixin(LitElement) {
|
|||||||
class=${classMap({
|
class=${classMap({
|
||||||
"edit-mode": this._editMode,
|
"edit-mode": this._editMode,
|
||||||
narrow: this.narrow,
|
narrow: this.narrow,
|
||||||
loaded: this._loaded,
|
loading: !this._loaded,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
@@ -1226,13 +1226,21 @@ class HUIRoot extends ViewTransitionMixin(LitElement) {
|
|||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
-moz-user-select: none;
|
-moz-user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
:host > div {
|
:host > div {
|
||||||
|
view-transition-name: hui-root-container;
|
||||||
|
}
|
||||||
|
:host > div.loading {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: opacity 0.3s ease-in;
|
|
||||||
}
|
}
|
||||||
:host > div.loaded {
|
|
||||||
opacity: 1;
|
@media (prefers-reduced-motion: no-preference) {
|
||||||
|
::view-transition-new(hui-root-container) {
|
||||||
|
animation: fade-in var(--ha-animation-layout-duration) ease-out;
|
||||||
|
animation-delay: var(--ha-animation-layout-delay-base);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
background-color: var(--app-header-background-color);
|
background-color: var(--app-header-background-color);
|
||||||
color: var(--app-header-text-color, white);
|
color: var(--app-header-text-color, white);
|
||||||
@@ -1281,7 +1289,6 @@ class HUIRoot extends ViewTransitionMixin(LitElement) {
|
|||||||
padding: 0px 12px;
|
padding: 0px 12px;
|
||||||
font-weight: var(--ha-font-weight-normal);
|
font-weight: var(--ha-font-weight-normal);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
view-transition-name: layout-fade-in;
|
|
||||||
}
|
}
|
||||||
.narrow .toolbar {
|
.narrow .toolbar {
|
||||||
padding: 0 4px;
|
padding: 0 4px;
|
||||||
|
|||||||
Reference in New Issue
Block a user