mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-15 22:10:20 +00:00
* Setup base animation styles * Add fade out to launch screen * Cleanup * Set opacity before removing element * Remove * Final * Use computed duration for timeout * Add skip animation prop * Swap * Use common function and fix issue
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import type { TemplateResult } from "lit";
|
|
import { render } from "lit";
|
|
import { parseAnimationDuration } from "../common/util/parse-animation-duration";
|
|
|
|
const removeElement = (
|
|
launchScreenElement: HTMLElement,
|
|
skipAnimation: boolean
|
|
) => {
|
|
if (skipAnimation) {
|
|
launchScreenElement.parentElement?.removeChild(launchScreenElement);
|
|
return;
|
|
}
|
|
|
|
launchScreenElement.classList.add("removing");
|
|
|
|
const durationFromCss = getComputedStyle(document.documentElement)
|
|
.getPropertyValue("--ha-animation-base-duration")
|
|
.trim();
|
|
|
|
setTimeout(() => {
|
|
launchScreenElement.parentElement?.removeChild(launchScreenElement);
|
|
}, parseAnimationDuration(durationFromCss));
|
|
};
|
|
|
|
export const removeLaunchScreen = () => {
|
|
const launchScreenElement = document.getElementById("ha-launch-screen");
|
|
if (!launchScreenElement?.parentElement) {
|
|
return;
|
|
}
|
|
|
|
if (document.startViewTransition) {
|
|
document.startViewTransition(() => {
|
|
removeElement(launchScreenElement, false);
|
|
});
|
|
} else {
|
|
// Fallback: Direct removal without transition
|
|
removeElement(launchScreenElement, true);
|
|
}
|
|
};
|
|
|
|
export const renderLaunchScreenInfoBox = (content: TemplateResult) => {
|
|
const infoBoxElement = document.getElementById("ha-launch-screen-info-box");
|
|
if (infoBoxElement) {
|
|
render(content, infoBoxElement);
|
|
}
|
|
};
|