From f689bb0eeb605813adf7070f5812295468ac4393 Mon Sep 17 00:00:00 2001 From: DeepSeek Harness Date: Thu, 22 Oct 2026 18:30:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(animation):=20=E6=81=A2=E5=A4=8D=E8=BF=9B?= =?UTF-8?q?=E5=9C=BA=E5=8A=A8=E7=94=BB=EF=BC=8C=E4=B8=8D=E5=86=8D=E8=A2=AB?= =?UTF-8?q?=20reduced-motion=20=E5=85=A8=E5=B1=80=E5=90=83=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因:clear.css 里从模板继承的 prefers-reduced-motion 规则把所有元素的 transition-duration / animation-duration 强制成 0.01ms。本机(Windows 关闭动画、 VM/RDP 环境)会命中该媒体查询,于是每个过渡都只剩延迟、没有插值——字幕、名次变化、 wipe 全部变成一格一格的瞬移,看起来就是动画被吃掉。 - clear.css:只保留 scroll-behavior 的降级,不再压掉动画时长。这个项目本身 就是动画演示,全局关动画等于关掉产品 - useChyronDirector:把固定的 50ms 定时器换成双 requestAnimationFrame, 保证"闭合帧"真正绘制之后才切到开启状态;隐藏标签页时用定时器兜底 - broadcastGraphicsSlice:修掉 incrementChyronsOpenState 里复制粘贴导致的 二次自增("下一步"会一次跳两级,进场从关闭直接跳到全开) 验证:BaseBlack 的 transition-duration 由 1e-05s 恢复为 0.8s / 0.667s, 不透明度在 825→1690ms 之间逐帧插值(49 个不同值 / 70 帧),控制台无报错。 --- src/clear.css | 16 ++++++++++--- .../broadcast/director/useChyronDirector.ts | 23 +++++++++++++++---- .../graphics/broadcastGraphicsSlice.ts | 13 ++++------- 3 files changed, 37 insertions(+), 15 deletions(-) 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;