From 3e12962add10a00c37d934f9e82cd8dc77a9a26f Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Mon, 17 Jul 2023 12:40:30 +0300 Subject: [PATCH] Fix intersaction Observer in fos-selections. --- fos/fos-selection/fos-selection.component.ts | 7 ++++--- fos/fos.component.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fos/fos-selection/fos-selection.component.ts b/fos/fos-selection/fos-selection.component.ts index e978ea88..64d50cfa 100644 --- a/fos/fos-selection/fos-selection.component.ts +++ b/fos/fos-selection/fos-selection.component.ts @@ -72,8 +72,9 @@ export class FosSelectionComponent { } else { this.activeSection = this.fos[0].id; } - - this.setObserver(); + if(typeof IntersectionObserver !== "undefined") { + this.setObserver(); + } this.cdr.detectChanges(); }); } @@ -93,7 +94,7 @@ export class FosSelectionComponent { this.subscriptions.push(this.keywordControl.valueChanges.pipe(debounceTime(500), distinctUntilChanged()).subscribe(value => { this.keyword = value; this.findMatches(this.keyword); - if (typeof document !== 'undefined') { + if (typeof IntersectionObserver !== 'undefined') { setTimeout(() => { this.setObserver(); }); diff --git a/fos/fos.component.ts b/fos/fos.component.ts index 90664f4b..49edfd5b 100644 --- a/fos/fos.component.ts +++ b/fos/fos.component.ts @@ -105,7 +105,7 @@ export class FosComponent implements OnInit, OnDestroy { this.subscriptions.push(this.keywordControl.valueChanges.pipe(debounceTime(500), distinctUntilChanged()).subscribe(value => { this.keyword = value; this.findMatches(this.keyword); - if (typeof document !== 'undefined') { + if (typeof IntersectionObserver !== 'undefined') { setTimeout(() => { this.setObserver(); });