From 1cff9e6eb2822c72b0f6b7982accec57956c2275 Mon Sep 17 00:00:00 2001 From: lobo Date: Wed, 21 Oct 2026 08:34:39 +0200 Subject: [PATCH] fix(algorithms): render sliders only after first browser render ngx-slider throws during prerender (no layout APIs on the server). Its ngOnDestroy then calls disconnect() on null, so about 1 in 10 prerender builds failed. Gate fractal and pendulum sliders on a signal set by afterNextRender. --- .../algorithms/fractal/fractal.component.html | 6 +- .../algorithms/fractal/fractal.component.ts | 9 ++- .../pendulum/pendulum.component.html | 64 ++++++++++--------- .../algorithms/pendulum/pendulum.component.ts | 9 ++- 4 files changed, 55 insertions(+), 33 deletions(-) diff --git a/src/app/pages/algorithms/fractal/fractal.component.html b/src/app/pages/algorithms/fractal/fractal.component.html index be75397..5a530cd 100644 --- a/src/app/pages/algorithms/fractal/fractal.component.html +++ b/src/app/pages/algorithms/fractal/fractal.component.html @@ -31,7 +31,11 @@
zoom_out - + @if (sliderReady()) { + + } @else { +
+ } zoom_in
diff --git a/src/app/pages/algorithms/fractal/fractal.component.ts b/src/app/pages/algorithms/fractal/fractal.component.ts index 8116a13..9ca9c5f 100644 --- a/src/app/pages/algorithms/fractal/fractal.component.ts +++ b/src/app/pages/algorithms/fractal/fractal.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit, signal} from '@angular/core'; +import {afterNextRender, Component, OnInit, signal} from '@angular/core'; import {Information} from '../information/information'; import {MatCard, MatCardContent, MatCardHeader, MatCardTitle} from '@angular/material/card'; import {TranslatePipe} from '@ngx-translate/core'; @@ -39,6 +39,13 @@ import {clampZoom, initialView, iterationsForZoom, zoomAroundPoint} from './frac styleUrl: './fractal.component.scss', }) export class FractalComponent implements OnInit { + // ngx-slider throws on the server (no layout APIs), so render it in the browser only + readonly sliderReady = signal(false); + + constructor() { + afterNextRender(() => this.sliderReady.set(true)); + } + algoInformation: AlgorithmInformation = { title: 'FRACTAL.EXPLANATION.TITLE', entries: [ diff --git a/src/app/pages/algorithms/pendulum/pendulum.component.html b/src/app/pages/algorithms/pendulum/pendulum.component.html index c9f42e0..b9c5950 100644 --- a/src/app/pages/algorithms/pendulum/pendulum.component.html +++ b/src/app/pages/algorithms/pendulum/pendulum.component.html @@ -5,39 +5,43 @@
-
-
-

{{ 'PENDULUM.TRAIL_DECAY_TIME' | translate }}

- -
-
-

{{ 'PENDULUM.ATTRACTION' | translate }}

- -
+ @if (sliderReady()) { +
+
+

{{ 'PENDULUM.TRAIL_DECAY_TIME' | translate }}

+ +
+
+

{{ 'PENDULUM.ATTRACTION' | translate }}

+ +
-
-

{{ 'PENDULUM.L1_LENGTH' | translate }}

- -
-
-

{{ 'PENDULUM.L2_LENGTH' | translate }}

- -
+
+

{{ 'PENDULUM.L1_LENGTH' | translate }}

+ +
+
+

{{ 'PENDULUM.L2_LENGTH' | translate }}

+ +
-
-

{{ 'PENDULUM.M1_MASS' | translate }}

- -
-
-

{{ 'PENDULUM.M2_MASS' | translate }}

- -
+
+

{{ 'PENDULUM.M1_MASS' | translate }}

+ +
+
+

{{ 'PENDULUM.M2_MASS' | translate }}

+ +
-
-

{{ 'PENDULUM.DAMPING' | translate }}

- -
-
+
+

{{ 'PENDULUM.DAMPING' | translate }}

+ +
+
+ } @else { +
+ }