Skip to content

Commit 110a1a5

Browse files
Added Repopulate Delay to Graphs when Resizing
- Instead of shuttering when the graphs resize it now has a half second delay when the user stops resizing.
1 parent 82abc91 commit 110a1a5

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/graphMonth.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ async function populate30DayGraph(scope, id){
134134
monthHoursGraph = createChart();
135135
}
136136

137+
let resizeTimer;
138+
137139
window.addEventListener('resize', () => {
140+
clearTimeout(resizeTimer);
138141
// Destroy the existing chart instances for all canvases
139142
if (weekCompareGraph) {
140143
weekCompareGraph.destroy();
@@ -145,9 +148,10 @@ window.addEventListener('resize', () => {
145148
if (monthHoursGraph) {
146149
monthHoursGraph.destroy();
147150
}
148-
149-
// Recreate the chart instances for all canvases with updated dimensions
150-
weekCompareGraph = createWeekCompare();
151-
annualHoursGraph = createAnnualHoursGraph();
152-
monthHoursGraph = createChart();
151+
152+
resizeTimer = setTimeout(() => {
153+
weekCompareGraph = createWeekCompare();
154+
annualHoursGraph = createAnnualHoursGraph();
155+
monthHoursGraph = createChart();
156+
}, 500);
153157
});

0 commit comments

Comments
 (0)