Skip to content

Commit

Permalink
Fix RangeError when zooming with zero view range
Browse files Browse the repository at this point in the history
When the view range is zero, the zooming mouse and keyboard handlers
cause a RangeError due to a division by zero. Abort the zooming early
instead.

Change-Id: Ib2301261cbbf9acce3be8763d71350d72e608294
Signed-off-by: Patrick Tasse <patrick.tasse@ericsson.com>
  • Loading branch information
PatrickTasse committed Oct 13, 2021
1 parent ed2f8fe commit 23af71d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions timeline-chart/src/layer/time-graph-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ export class TimeGraphChart extends TimeGraphChartLayer {
}

adjustZoom(zoomPosition: number | undefined, hasZoomedIn: boolean) {
if (this.unitController.viewRangeLength <= 0) {
return;
}
if (zoomPosition === undefined) {
const start = this.getPixel(this.unitController.selectionRange ? this.unitController.selectionRange.start - this.unitController.viewRange.start : BigInt(0));
const end = this.getPixel(this.unitController.selectionRange ? this.unitController.selectionRange.end - this.unitController.viewRange.start : this.unitController.viewRangeLength);
Expand Down

0 comments on commit 23af71d

Please sign in to comment.