diff --git a/shopfloor-dashboard/index.html b/shopfloor-dashboard/index.html index a4a0f59..9b6af95 100644 --- a/shopfloor-dashboard/index.html +++ b/shopfloor-dashboard/index.html @@ -700,6 +700,8 @@ let upcomingEvents = []; let currentUpcomingIndex = 0; let upcomingCarouselInterval = null; + let isTransitioning = false; + let pendingDataRender = null; // Get business unit from URL parameter function getBusinessUnitFromURL() { @@ -749,8 +751,15 @@ }); } - // Render events on the page + // Render events on the page (with smart delay during transitions) function renderEvents(data) { + // If carousel is mid-transition, delay the render + if (isTransitioning) { + console.log('Carousel: Transition in progress, delaying render by 800ms'); + pendingDataRender = data; + return; + } + const container = document.getElementById('eventsContainer'); let html = ''; @@ -962,6 +971,9 @@ console.log(`Carousel: Rotating from index ${currentUpcomingIndex} to ${(currentUpcomingIndex + 1) % upcomingEvents.length} (${items.length} total items)`); + // Mark transition as active + isTransitioning = true; + const currentItem = items[currentUpcomingIndex]; const nextIndex = (currentUpcomingIndex + 1) % upcomingEvents.length; const nextItem = items[nextIndex]; @@ -978,6 +990,17 @@ setTimeout(() => { currentItem.classList.remove('exit-up'); currentItem.classList.add('enter-down'); + + // Mark transition as complete + isTransitioning = false; + + // If there's pending data to render, render it now + if (pendingDataRender) { + console.log('Carousel: Transition complete, rendering pending data'); + const dataToRender = pendingDataRender; + pendingDataRender = null; + renderEvents(dataToRender); + } }, 800); // Match transition duration currentUpcomingIndex = nextIndex;