Skip to content

Commit

Permalink
Chart freezes when zooming using right mouse button
Browse files Browse the repository at this point in the history
Signed-off-by: muddana-satish <satish.muddana@ericsson.com>
  • Loading branch information
muddana-satish authored and PatrickTasse committed Jun 15, 2021
1 parent 031e5b5 commit 53a52f0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions timeline-chart/src/layer/time-graph-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,17 @@ export class TimeGraphChart extends TimeGraphChartLayer {
this.mouseEndX = e.offsetX;
const start = this.mouseZoomingStart;
const end = this.unitController.viewRange.start + (this.mouseEndX / this.stateController.zoomFactor);
if (start !== end) {
if (start !== end && this.unitController.viewRangeLength > 1) {
let newViewStart = Math.max(Math.min(start, end), this.unitController.viewRange.start);
let newViewEnd = Math.min(Math.max(start, end), this.unitController.viewRange.end);
if (newViewEnd - newViewStart < 1) {
const center = (newViewStart + newViewEnd) / 2;
newViewStart = center - 0.5;
newViewEnd = center + 0.5;
}
this.unitController.viewRange = {
start: Math.max(Math.min(start, end), this.unitController.viewRange.start),
end: Math.min(Math.max(start, end), this.unitController.viewRange.end)
start: newViewStart,
end: newViewEnd
}
}
this.stage.cursor = 'default';
Expand Down

0 comments on commit 53a52f0

Please sign in to comment.