Skip to content

Commit 7e6a3d9

Browse files
committed
fix pxPerSec becomes too large when true maxTrackSec is not retrieved yet
1 parent 670253c commit 7e6a3d9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/prototypes/MainViewer/MainViewer.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,15 @@ function MainViewer(props: MainViewerProps) {
275275
Math.min(Math.max(_startSec, 0), Math.max(maxEndSec - width / Math.max(_pxPerSec, 1e-8), 0)),
276276
);
277277

278-
const normalizePxPerSec = useEvent((_pxPerSec, _startSec) =>
279-
Math.min(
280-
Math.max(_pxPerSec, width / Math.max(maxTrackSec - _startSec, 1e-8), 1e-8),
281-
Math.max(MAX_PX_PER_SEC, width / Math.max(maxTrackSec - _startSec, 1e-8), 1e-8),
282-
),
283-
);
278+
const normalizePxPerSec = useEvent((_pxPerSec, _startSec) => {
279+
if (maxTrackSec - _startSec < 1e-6) {
280+
return Math.min(_pxPerSec, MAX_PX_PER_SEC, 1e-8);
281+
}
282+
return Math.min(
283+
Math.max(_pxPerSec, width / (maxTrackSec - _startSec), 1e-8),
284+
Math.max(MAX_PX_PER_SEC, width / (maxTrackSec - _startSec)),
285+
);
286+
});
284287

285288
const updateLensParams = useEvent(
286289
(params: OptionalLensParams, turnOffFollowCursor: boolean = true) => {

0 commit comments

Comments
 (0)