Skip to content

Commit e8f027f

Browse files
committed
fix(webapp): honour a controlled morph amount under reduced motion
The orb and logo morph painted a single resting frame and never repainted, so with reduced motion enabled the scrubber looked dead. They now render the controlled amount and repaint when it changes, while still refusing to run the animation loop.
1 parent ef77c2a commit e8f027f

1 file changed

Lines changed: 25 additions & 6 deletions

File tree

  • apps/webapp/app/routes/storybook.ai-agent

apps/webapp/app/routes/storybook.ai-agent/route.tsx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -878,8 +878,18 @@ function AgentOrb({
878878
typeof matchMedia !== "undefined" && matchMedia("(prefers-reduced-motion: reduce)").matches;
879879

880880
if (reduced) {
881-
drawFrame(ctx, dpr, 0, 0, cfg);
882-
return;
881+
// No animation, but a controlled amount (the scrubber) is a static pose,
882+
// so still honour it and repaint when it changes.
883+
const paint = () => {
884+
const amount = controlledRef.current ?? (activeRef.current ? 1 : 0);
885+
amountRef.current = amount;
886+
drawFrame(ctx, dpr, amount, 0, cfg);
887+
};
888+
wakeRef.current = paint;
889+
paint();
890+
return () => {
891+
wakeRef.current = () => {};
892+
};
883893
}
884894

885895
let raf = 0;
@@ -1157,10 +1167,19 @@ function AgentLogoMorph({
11571167
const reduced =
11581168
typeof matchMedia !== "undefined" && matchMedia("(prefers-reduced-motion: reduce)").matches;
11591169
if (reduced) {
1160-
setLogo(0);
1161-
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
1162-
ctx.clearRect(0, 0, size, size);
1163-
return;
1170+
// Same as the orb: freeze the animation, but still render a controlled
1171+
// amount so the scrubber keeps working.
1172+
const paint = () => {
1173+
const amount = controlledRef.current ?? (activeRef.current ? 1 : 0);
1174+
amountRef.current = amount;
1175+
setLogo(amount);
1176+
drawLogoMorphFrame(ctx, dpr, amount, 0, cfg);
1177+
};
1178+
wakeRef.current = paint;
1179+
paint();
1180+
return () => {
1181+
wakeRef.current = () => {};
1182+
};
11641183
}
11651184

11661185
let raf = 0;

0 commit comments

Comments
 (0)