Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(website): the scrubbed clip was invisible in production only

Etienne Lescotda80581d0c44
diff --git a/website/src/components/Walkthrough/styles.module.css b/website/src/components/Walkthrough/styles.module.css
index a0ac44e6f..84414478a 100644
--- a/website/src/components/Walkthrough/styles.module.css
+++ b/website/src/components/Walkthrough/styles.module.css
@@ -414,7 +414,15 @@ span.replay {
transition: opacity 0.18s ease;
}
-.clipReady {
+/* Compound, not `.clipReady` alone, and this is not tidiness.
+ `.clipReady { opacity: 1 }` and `.clip { opacity: 0 }` have equal specificity,
+ so which wins is decided by source order — and the production CSS optimiser
+ merges rules that share a declaration, so this one got folded in with
+ Infima's `.alert .close:hover` and hoisted ABOVE `.clip`. The result was a
+ clip that scrubbed perfectly at opacity 0 behind a poster that never moved:
+ correct in dev, invisible in the build, and no error anywhere. Raising the
+ specificity makes the outcome independent of what the optimiser does. */
+.clip.clipReady {
opacity: 1;
}
@@ -479,7 +487,10 @@ span.replay {
animation-fill-mode: forwards;
}
-.railDone {
+/* Compound for the same reason as `.clip.clipReady` above: `transform` is a
+ common declaration, and a same-specificity rule that the optimiser is free to
+ reorder is not a rule, it is a coin toss. */
+.railFill.railDone {
transform: scaleX(1);
}
diff --git a/website/src/components/Walkthrough/useScrub.ts b/website/src/components/Walkthrough/useScrub.ts
index 81125831f..65d71eabf 100644
--- a/website/src/components/Walkthrough/useScrub.ts
+++ b/website/src/components/Walkthrough/useScrub.ts
@@ -129,6 +129,13 @@ export function useScrub({ band, video, seconds, enabled }: Options): {
seeking.current = false;
};
const loaded = () => setReady(true);
+ // The state is read as well as subscribed to. `loadeddata` fires once, and
+ // an element whose file is already in the HTTP cache reaches HAVE_CURRENT_DATA
+ // before an effect can attach anything — so on a warm load the event is
+ // simply gone, `ready` never turns true, and the clip scrubs correctly at
+ // opacity 0 behind a poster that never changes. It looks exactly like a
+ // feature that does not work, and only on the second visit.
+ if (v.readyState >= 2) setReady(true);
v.addEventListener("seeked", done);
v.addEventListener("error", done);
v.addEventListener("loadeddata", loaded);