From 2e6e885071f709b4a52750f4d138567c1343ceec Mon Sep 17 00:00:00 2001 From: "Florine W. Dekker" Date: Sun, 17 Apr 2022 17:44:15 +0200 Subject: [PATCH] Use correct bounds checking on maximum --- src/main/js/Painter.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/js/Painter.ts b/src/main/js/Painter.ts index 66092ce..f299a94 100644 --- a/src/main/js/Painter.ts +++ b/src/main/js/Painter.ts @@ -56,7 +56,7 @@ export class Painter { public set scrollX(scrollX: number) { const min = this.model?.minX; - const max = this.model?.maxX; + const max = this.model?.maxX != null ? Math.max(0, this.model.maxX - this.width) : null; this._scrollX = min != null && scrollX < min ? min : (max != null && scrollX > max ? max : scrollX); } @@ -72,7 +72,7 @@ export class Painter { public set scrollY(scrollY: number) { const min = this.model?.minY; - const max = this.model?.maxY; + const max = this.model?.maxY != null ? Math.max(0, this.model.maxY - this.height) : null; this._scrollY = min != null && scrollY < min ? min : (max != null && scrollY > max ? max : scrollY); } @@ -142,8 +142,8 @@ export class Painter { this.ctx.save(); this.ctx.scale(this.scale, this.scale); this.ctx.translate(0.2, 0.2); - this.drawBoundaries(); this.drawPrimes(); + this.drawBoundaries(); this.ctx.restore(); } @@ -159,6 +159,11 @@ export class Painter { this.ctx.restore(); } + /** + * Draws the boundaries of the `Model`. + * + * @private + */ private drawBoundaries(): void { this.ctx.save(); this.ctx.beginPath();