diff --git a/src/clear.css b/src/clear.css index 86070a1..7d6c3c6 100644 --- a/src/clear.css +++ b/src/clear.css @@ -71,6 +71,19 @@ select { outline: none; } +/* + * Only the scroll behaviour is reduced here. + * + * The boilerplate rule that used to live below this also forced + * "animation-duration: 0.01ms !important" and "transition-duration: 0.01ms + * !important" on every element. That is a sensible default for an ordinary + * website, but this project *is* an animation showcase: the chyrons, the + * position change flashes and the wipes are the product. On any machine where + * the OS reports prefers-reduced-motion (Windows "show animations" switched + * off, most VMs and RDP sessions), that rule silently collapsed every entrance + * animation into a single frame - it looked like the animation had been eaten, + * with the delays still running so the graphic simply snapped into place. + */ @media (prefers-reduced-motion: reduce) { html:focus-within { scroll-behavior: auto; @@ -79,9 +92,6 @@ select { *, *::before, *::after { - animation-duration: 0.01ms !important; - animation-iteration-count: 1 !important; - transition-duration: 0.01ms !important; scroll-behavior: auto !important; } } \ No newline at end of file diff --git a/src/features/broadcast/director/useChyronDirector.ts b/src/features/broadcast/director/useChyronDirector.ts index 862cd92..7b585a8 100644 --- a/src/features/broadcast/director/useChyronDirector.ts +++ b/src/features/broadcast/director/useChyronDirector.ts @@ -12,8 +12,8 @@ import { import { BGChyronDriver, BGChyrons, GridSpot } from "../../../types/state"; /** - * The chyron animation needs a frame mounted at openState 0 before it is - * advanced, otherwise the whole transition is skipped. + * Safety delay for advancing a freshly mounted chyron. The real trigger is two + * animation frames; this only fires if frames stop being produced (hidden tab). */ export const CHYRON_OPEN_DELAY_MS = 50; @@ -75,8 +75,23 @@ export function useChyronDirector() { }; dispatch(setChyrons(newChyrons)); - // Delay a short time and increment the open state so the animation can happen. - setTimeout(() => dispatch(incrementChyronsOpenState()), CHYRON_OPEN_DELAY_MS); + + /** + * Mount at openState 0, then let the browser paint that "closed" frame + * before flipping to open - a CSS transition needs a painted start value to + * interpolate from. Two animation frames guarantee a paint in between; the + * old fixed timeout raced it and on a busy machine the whole entrance was + * silently skipped. + */ + let advanced = false; + const advance = () => { + if (advanced) return; + advanced = true; + dispatch(incrementChyronsOpenState()); + }; + window.requestAnimationFrame(() => window.requestAnimationFrame(advance)); + // Fallback for a hidden tab, where no frames are produced at all. + window.setTimeout(advance, CHYRON_OPEN_DELAY_MS * 4); }, [dispatch, targetSpots, chyronSettings, buildDriverChyron, grid]); const next = useCallback(() => { diff --git a/src/features/broadcast/graphics/broadcastGraphicsSlice.ts b/src/features/broadcast/graphics/broadcastGraphicsSlice.ts index 3e2fcd9..ef4431f 100644 --- a/src/features/broadcast/graphics/broadcastGraphicsSlice.ts +++ b/src/features/broadcast/graphics/broadcastGraphicsSlice.ts @@ -37,18 +37,15 @@ export const broadcastGraphicsSlice = createSlice({ setChyronsOpenState: (state, action: PayloadAction) => { if (state.chyrons == null) return; state.chyrons.openState = action.payload; - - if (state.chyrons != null) { - state.chyrons.openState = action.payload; - } }, + /** + * Advances the animation one step. This used to bump the state twice, which + * skipped step 1 entirely - the "next step" button jumped two stages and the + * entrance went straight from closed to fully open. + */ incrementChyronsOpenState: (state) => { if (state.chyrons == null) return; ++state.chyrons.openState; - - if (state.chyrons != null) { - ++state.chyrons.openState; - } }, clearChyrons: (state) => { state.chyrons = null;