commit fee5f96cc1af628aa490beccce98de1b7ba7e43b
parent 11dbf6f8eebf9d3da891a7bfa9b391ea95432ab4
Author: Milan Pässler <me@pbb.lc>
Date: Wed, 22 Jul 2020 22:56:32 +0200
parent 11dbf6f8eebf9d3da891a7bfa9b391ea95432ab4
Author: Milan Pässler <me@pbb.lc>
Date: Wed, 22 Jul 2020 22:56:32 +0200
canvas: don't reset offset when loading more
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/client/js/canvas.js b/client/js/canvas.js @@ -57,8 +57,8 @@ const textCache = {}; let textCacheWidth; let textCacheDpr; -export const setupCanvas = (data) => { - canvasState.offsetX = (window.innerWidth / dpr) > 600 ? 120 : 60, +export const setupCanvas = (data, isUpdate) => { + if (!isUpdate) canvasState.offsetX = (window.innerWidth / dpr) > 600 ? 120 : 60; canvas = document.getElementById('canvas'); ctx = canvas.getContext('2d'); canvasState.journeys = Object.keys(data.journeys).sort((a, b) => Number(a) - Number(b)).map(k => data.journeys[k]);
diff --git a/client/js/journeysView.js b/client/js/journeysView.js @@ -93,7 +93,7 @@ const journeyOverviewTemplate = (data, key) => { </tr>`; } -export const journeysView = async (match) => { +export const journeysView = async (match, isUpdate) => { const reqId = match[0]; data = getCache('journeys', reqId); @@ -106,7 +106,7 @@ export const journeysView = async (match) => { render(journeysTemplate(data), ElementById('content')) if (dataStorage.settings.journeysViewMode === 'canvas') { - setupCanvas(data); + setupCanvas(data, isUpdate); } }; @@ -144,5 +144,5 @@ export const moreJourneys = async (reqId, mode) => { data.journeys = {...data.journeys, ...newData.journeys}; addCache('journeys', data); - journeysView([reqId]); + journeysView([reqId], true); };