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) { async function animateCalendarZoomIn(sourceElement: HTMLElement | null, apply: () => void) {
const fromRect = getElementRectInCalendar(sourceElement); const fromRect = getElementRectInCalendar(sourceElement);
const viewportRect = getCalendarViewportRect(); const viewportRect = getCalendarViewportRect();
@@ -2299,12 +2305,13 @@ async function animateCalendarZoomIn(sourceElement: HTMLElement | null, apply: (
calendarZoomBusy.value = true; calendarZoomBusy.value = true;
try { try {
primeCalendarRect(fromRect); primeCalendarRect(fromRect);
morphCalendarRect(viewportRect);
const switchLag = 260;
await waitMs(Math.max(0, CALENDAR_ZOOM_DURATION_MS - switchLag));
calendarSceneMasked.value = true; calendarSceneMasked.value = true;
await nextTick();
apply(); apply();
await nextTick(); await nextTick();
morphCalendarRect(viewportRect); await waitMs(switchLag);
await waitCalendarZoom();
} finally { } finally {
calendarSceneMasked.value = false; calendarSceneMasked.value = false;
calendarZoomBusy.value = false; calendarZoomBusy.value = false;