Skip to content

Commit

Permalink
Fix timeline rescale glitch
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfdsilva committed Aug 2, 2023
1 parent 3954dc6 commit 00e3c39
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/scripts/components/exploration/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ export function useScales() {
const scaled = useMemo(() => {
if (!main) return undefined;
return rescaleX(main, zoomTransform.x, zoomTransform.k);
}, [main, zoomTransform.x, zoomTransform.k]);
// We want to scale this scale only when the zoom transform changes.
// The zoom transform is what dictates the current timeline view so it is
// important that it drives the scale. Because the main changes before the
// zoom transform we can't include it in the deps, otherwise we'd have a
// weird midway render in the timeline when this scale had reacted to the
// main change but not to the zoom transform change.
}, [zoomTransform.x, zoomTransform.k]);

return { main, scaled };
// In the first run the scaled and main scales are the same.
return { main, scaled: scaled ?? main };
}

0 comments on commit 00e3c39

Please sign in to comment.