Bug fix: avoid NaN in helper
This commit is contained in:
parent
5af8f0c319
commit
48c84a7efa
|
@ -109,7 +109,12 @@ export const Waveform: React.FC<Props> = ({
|
||||||
// helpers
|
// helpers
|
||||||
|
|
||||||
const frameToCanvasX = (frame: number): number => {
|
const frameToCanvasX = (frame: number): number => {
|
||||||
const pixelsPerFrame = CanvasLogicalWidth / (viewport.end - viewport.start);
|
const numFrames = viewport.end - viewport.start;
|
||||||
|
if (numFrames == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const pixelsPerFrame = CanvasLogicalWidth / numFrames;
|
||||||
return Math.round((frame - viewport.start) * pixelsPerFrame);
|
return Math.round((frame - viewport.start) * pixelsPerFrame);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue