diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index b79d1e9..377fb35 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -150,6 +150,7 @@ function App(): JSX.Element { offsetPixels={offsetPixels} height={80} position={position} + selection={viewport} onSelectionStart={(x1: number) => { console.log('onSelectionStart', x1); }} diff --git a/frontend/src/Overview.tsx b/frontend/src/Overview.tsx index 15026f6..122fe86 100644 --- a/frontend/src/Overview.tsx +++ b/frontend/src/Overview.tsx @@ -12,6 +12,7 @@ interface Props { height: number; offsetPixels: number; position: number; + selection: Frames; onSelectionStart: (x1: number) => void; onSelectionChange: (selection: Frames) => void; } @@ -33,13 +34,13 @@ export const Overview: React.FC = ({ height, offsetPixels, position, + selection, onSelectionStart, onSelectionChange, }: Props) => { const hudCanvasRef = useRef(null); const [peaks, setPeaks] = useState>(from([])); const [mode, setMode] = useState(Mode.Normal); - const [selection, setSelection] = useState({ ...emptySelection }); const [newSelection, setNewSelection] = useState({ ...emptySelection }); const [dragStart, setDragStart] = useState(0); @@ -142,10 +143,6 @@ export const Overview: React.FC = ({ onSelectionStart(newSelection.start); }, [newSelection]); - useEffect(() => { - onSelectionChange({ ...selection }); - }, [selection]); - // handlers const handleMouseDown = (evt: MouseEvent) => { @@ -207,7 +204,7 @@ export const Overview: React.FC = ({ } setMode(Mode.Normal); - setSelection(newSelection); + onSelectionChange({ ...newSelection }); }; // render component