feat(settings/clock/time): intro and outro animation

This commit is contained in:
2026-02-06 13:12:25 +01:00
parent cadfc3b974
commit 42ad35b432

View File

@@ -1,6 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { SettingsBottomScreenNumberInput as NumberInput } from "#components"; import { SettingsBottomScreenNumberInput as NumberInput } from "#components";
import { useIntervalFn } from "@vueuse/core"; import { useIntervalFn } from "@vueuse/core";
import gsap from "gsap";
const store = useSettingsStore(); const store = useSettingsStore();
const { assets } = useAssets(); const { assets } = useAssets();
@@ -12,17 +13,62 @@ useIntervalFn(() => {
now.value = new Date(); now.value = new Date();
}, 1000); }, 1000);
const handleCancel = () => { const SLIDE_OFFSET = 96;
const SLIDE_DURATION = 0.25;
const animation = reactive({
offsetY: SLIDE_OFFSET,
opacity: 0,
});
const hourRef = useTemplateRef<InstanceType<typeof NumberInput>>("hour");
const minuteRef = useTemplateRef<InstanceType<typeof NumberInput>>("minute");
const animateIntro = async () => {
await Promise.all([
hourRef.value?.animateIntro(),
minuteRef.value?.animateIntro(),
gsap
.timeline()
.to(animation, { offsetY: 0, duration: SLIDE_DURATION, ease: "none" }, 0)
.to(animation, { opacity: 1, duration: SLIDE_DURATION, ease: "none" }, 0),
]);
};
const animateOutro = async () => {
await Promise.all([
hourRef.value?.animateOutro(),
minuteRef.value?.animateOutro(),
gsap
.timeline()
.to(
animation,
{ offsetY: SLIDE_OFFSET, duration: SLIDE_DURATION, ease: "none" },
0,
)
.to(animation, { opacity: 0, duration: SLIDE_DURATION, ease: "none" }, 0),
]);
};
onMounted(() => {
animateIntro();
});
const handleCancel = async () => {
await animateOutro();
store.closeSubMenu(); store.closeSubMenu();
}; };
const handleConfirm = () => { const handleConfirm = async () => {
await animateOutro();
store.closeSubMenu(); store.closeSubMenu();
}; };
onRender((ctx) => { onRender((ctx) => {
assets.images.home.topScreen.background.draw(ctx, 0, 0); assets.images.home.topScreen.background.draw(ctx, 0, 0);
ctx.globalAlpha = animation.opacity;
ctx.translate(0, animation.offsetY);
assets.images.settings.bottomScreen.clock.timeColon.draw(ctx, 112, 63); assets.images.settings.bottomScreen.clock.timeColon.draw(ctx, 112, 63);
}); });
@@ -31,12 +77,14 @@ defineOptions({ render: () => null });
<template> <template>
<NumberInput <NumberInput
ref="hour"
:model-value="now.getHours()" :model-value="now.getHours()"
:title="$t('settings.clock.time.hour')" :title="$t('settings.clock.time.hour')"
:x="4 * 16 - 1" :x="4 * 16 - 1"
:disabled="true" :disabled="true"
/> />
<NumberInput <NumberInput
ref="minute"
:model-value="now.getMinutes()" :model-value="now.getMinutes()"
:title="$t('settings.clock.time.minute')" :title="$t('settings.clock.time.minute')"
:x="9 * 16 - 1" :x="9 * 16 - 1"