Skip to content

Commit 2a9ff79

Browse files
committed
Heatmap attempting requestAnimationFrame()
1 parent b72548e commit 2a9ff79

1 file changed

Lines changed: 19 additions & 15 deletions

File tree

src/app/pages/circular-heatmap/circular-heatmap.component.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -143,22 +143,26 @@ export class CircularHeatmapComponent implements OnInit, OnDestroy {
143143
// Reactively handle theme changes (if user toggles later)
144144
this.themeService.theme$.pipe(takeUntil(this.destroy$)).subscribe((theme: string) => {
145145
console.log(`${perfNow()}s: themeService.pipe: Theme changed to:`, theme);
146-
const css = getComputedStyle(document.body);
147-
this.theme_colors = {
148-
background: css.getPropertyValue('--heatmap-background').trim(),
149-
filled: css.getPropertyValue('--heatmap-filled').trim(),
150-
disabled: css.getPropertyValue('--heatmap-disabled').trim(),
151-
cursor: css.getPropertyValue('--heatmap-cursor-hover').trim(),
152-
stroke: css.getPropertyValue('--heatmap-stroke').trim(),
153-
};
154-
console.debug(`${perfNow()}s: themeService.pipe: Heatmap theme colors:`, this.theme_colors);
155-
if (!this.theme_colors['background'] || !this.theme_colors['filled']) {
156-
console.debug(css);
157-
debugger;
158-
}
146+
console.log(`${perfNow()}s: themeService.pipe: bk.gr col: '${getComputedStyle(document.body).getPropertyValue('--heatmap-background').trim()}'`);
147+
// Wait for next animation frame to ensure CSS variables are updated
148+
requestAnimationFrame(() => {
149+
const css = getComputedStyle(document.body);
150+
this.theme_colors = {
151+
background: css.getPropertyValue('--heatmap-background').trim(),
152+
filled: css.getPropertyValue('--heatmap-filled').trim(),
153+
disabled: css.getPropertyValue('--heatmap-disabled').trim(),
154+
cursor: css.getPropertyValue('--heatmap-cursor-hover').trim(),
155+
stroke: css.getPropertyValue('--heatmap-stroke').trim(),
156+
};
157+
console.debug(`${perfNow()}s: themeService.pipe: Heatmap theme colors:`, this.theme_colors);
158+
if (!this.theme_colors['background'] || !this.theme_colors['filled']) {
159+
console.debug(css);
160+
debugger;
161+
}
159162

160-
// Repaint segments with new theme
161-
this.reColorHeatmap();
163+
// Repaint segments with new theme
164+
this.reColorHeatmap();
165+
});
162166
});
163167
}
164168

0 commit comments

Comments
 (0)