From baa645f5ece348f911c93cc31d05ffbb66b5f0ee Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Thu, 18 Jun 2020 09:30:50 -0400 Subject: [PATCH] Make the vertical scale scroll with movement --- macrovision.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/macrovision.js b/macrovision.js index 45219cbe..14e60215 100644 --- a/macrovision.js +++ b/macrovision.js @@ -375,8 +375,16 @@ function drawVerticalScale(ifDirty = false) { return; function drawTicks(/** @type {CanvasRenderingContext2D} */ ctx, pixelsPer, heightPer) { let total = heightPer.clone(); - total.value = math.unit(config.y, "meters").toNumber(config.unit); - for (let y = ctx.canvas.clientHeight - 50; y >= 50; y -= pixelsPer) { + total.value = config.y; + let y = ctx.canvas.clientHeight - 50; + + let offset = total.toNumber("meters") % heightPer.toNumber("meters"); + + y += offset / heightPer.toNumber("meters") * pixelsPer; + total = math.subtract(total, math.unit(offset, "meters")); + + console.log(offset) + for (; y >= 50; y -= pixelsPer) { drawTick(ctx, 50, y, total); total = math.add(total, heightPer); }