From ea8e13e90f681fcc73bf33eff4e89805d5340712 Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Fri, 5 Apr 2024 18:21:25 +0200 Subject: [PATCH] Make var names more precise --- components/chart/chart.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/components/chart/chart.js b/components/chart/chart.js index 350f584..b013730 100644 --- a/components/chart/chart.js +++ b/components/chart/chart.js @@ -134,14 +134,16 @@ const CycleChart = ({ navigate, setDate }) => { ) } - const getcomputedDateInView = () => { - const columnIndex = Math.floor(currentScrollPosition / CHART_COLUMN_WIDTH) - const leftIndex = - columnIndex + numberOfColumnsToRender >= columns.length + const getLeftmostComputedDateInView = () => { + const rightmostVisibleIndexInView = Math.floor( + currentScrollPosition / CHART_COLUMN_WIDTH + ) + const leftmostVisibleIndexInView = + rightmostVisibleIndexInView + numberOfColumnsToRender >= columns.length ? 153 - : columnIndex + numberOfColumnsToRender - // detect oldest visible day to render its month dynamically - return columns[leftIndex] + : rightmostVisibleIndexInView + numberOfColumnsToRender + // detect leftmost aka oldest visible day to render its month dynamically + return columns[leftmostVisibleIndexInView] } const renderColumn = ({ item }) => { @@ -181,7 +183,7 @@ const CycleChart = ({ navigate, setDate }) => { symptomsSectionHeight={symptomRowHeight} shouldShowTemperatureColumn={shouldShowTemperatureColumn} xAxisHeight={xAxisHeight} - computedDate={getcomputedDateInView()} + computedDate={getLeftmostComputedDateInView()} />