calendar: delay zoom-in content switch until end of morph

This commit is contained in:
Ruslan Bakiev
2026-02-23 07:37:45 +07:00
parent 222c90a239
commit 70c095bc67

View File

@@ -2287,6 +2287,12 @@ function waitCalendarZoom() {
});
}
function waitMs(ms: number) {
return new Promise<void>((resolve) => {
setTimeout(() => resolve(), ms);
});
}
async function animateCalendarZoomIn(sourceElement: HTMLElement | null, apply: () => void) {
const fromRect = getElementRectInCalendar(sourceElement);
const viewportRect = getCalendarViewportRect();
@@ -2299,12 +2305,13 @@ async function animateCalendarZoomIn(sourceElement: HTMLElement | null, apply: (
calendarZoomBusy.value = true;
try {
primeCalendarRect(fromRect);
morphCalendarRect(viewportRect);
const switchLag = 260;
await waitMs(Math.max(0, CALENDAR_ZOOM_DURATION_MS - switchLag));
calendarSceneMasked.value = true;
await nextTick();
apply();
await nextTick();
morphCalendarRect(viewportRect);
await waitCalendarZoom();
await waitMs(switchLag);
} finally {
calendarSceneMasked.value = false;
calendarZoomBusy.value = false;