From aa10b35f7aa54c3f2e40749f27010c4c7966cda0 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Tue, 4 Jul 2023 11:53:08 +0300 Subject: [PATCH] Fix ResizeObserver condition in landings and fs-modal --- .../dataProvider/dataProvider.component.ts | 6 +++--- .../organization/organization.component.ts | 3 ++- landingPages/project/project.component.ts | 7 ++++--- landingPages/result/resultLanding.component.ts | 8 ++++---- .../full-screen-modal.component.ts | 14 ++++++-------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/landingPages/dataProvider/dataProvider.component.ts b/landingPages/dataProvider/dataProvider.component.ts index 7b358153..2b4d1290 100644 --- a/landingPages/dataProvider/dataProvider.component.ts +++ b/landingPages/dataProvider/dataProvider.component.ts @@ -1,4 +1,4 @@ -import {ChangeDetectorRef, Component, ElementRef, HostListener, Input, ViewChild} from '@angular/core'; +import {ChangeDetectorRef, Component, ElementRef, Input, ViewChild} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {Meta, Title} from '@angular/platform-browser'; @@ -26,7 +26,6 @@ import {ResultPreview} from "../../utils/result-preview/result-preview"; import {IndexInfoService} from "../../utils/indexInfo.service"; import {properties} from "../../../../environments/environment"; import {Subscriber, Subscription, zip} from "rxjs"; -import {TabComponent} from "../../utils/tabs/tab.component"; import {OpenaireEntities} from "../../utils/properties/searchFields"; import {MetricsService} from '../../services/metrics.service'; import {NumberUtils} from '../../utils/number-utils.class'; @@ -358,7 +357,8 @@ export class DataProviderComponent { this.subscriptions.forEach(subscription => { if (subscription instanceof Subscriber) { subscription.unsubscribe(); - } else if (subscription instanceof (ResizeObserver || IntersectionObserver)) { + } else if ((typeof ResizeObserver != 'undefined' && subscription instanceof ResizeObserver) || + (typeof IntersectionObserver != 'undefined' && subscription instanceof IntersectionObserver)) { subscription.disconnect(); } }); diff --git a/landingPages/organization/organization.component.ts b/landingPages/organization/organization.component.ts index 25c88990..26330d41 100644 --- a/landingPages/organization/organization.component.ts +++ b/landingPages/organization/organization.component.ts @@ -280,7 +280,8 @@ export class OrganizationComponent { this.subscriptions.forEach(subscription => { if (subscription instanceof Subscriber) { subscription.unsubscribe(); - } else if (subscription instanceof (ResizeObserver || IntersectionObserver)) { + } else if ((typeof ResizeObserver != 'undefined' && subscription instanceof ResizeObserver) || + (typeof IntersectionObserver != 'undefined' && subscription instanceof IntersectionObserver)) { subscription.disconnect(); } }); diff --git a/landingPages/project/project.component.ts b/landingPages/project/project.component.ts index cf46334d..bc24e86c 100644 --- a/landingPages/project/project.component.ts +++ b/landingPages/project/project.component.ts @@ -1,4 +1,4 @@ -import {ChangeDetectorRef, Component, ElementRef, HostListener, Input, ViewChild} from '@angular/core'; +import {ChangeDetectorRef, Component, ElementRef, Input, ViewChild} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {Meta, Title} from '@angular/platform-browser'; @@ -25,7 +25,7 @@ import {StringUtils} from "../../utils/string-utils.class"; import {ResultPreview} from "../../utils/result-preview/result-preview"; import {SearchResult} from "../../utils/entities/searchResult"; import {IndexInfoService} from "../../utils/indexInfo.service"; -import {Subscriber, zip, Subscription} from "rxjs"; +import {Subscriber, Subscription, zip} from "rxjs"; import {properties} from "../../../../environments/environment"; import {Option} from "../../sharedComponents/input/input.component"; import {OpenaireEntities} from "../../utils/properties/searchFields"; @@ -380,7 +380,8 @@ export class ProjectComponent { this.subscriptions.forEach(subscription => { if (subscription instanceof Subscriber) { subscription.unsubscribe(); - } else if (subscription instanceof (ResizeObserver || IntersectionObserver)) { + } else if ((typeof ResizeObserver != 'undefined' && subscription instanceof ResizeObserver) || + (typeof IntersectionObserver != 'undefined' && subscription instanceof IntersectionObserver)) { subscription.disconnect(); } }); diff --git a/landingPages/result/resultLanding.component.ts b/landingPages/result/resultLanding.component.ts index a44acc1d..0f454bee 100644 --- a/landingPages/result/resultLanding.component.ts +++ b/landingPages/result/resultLanding.component.ts @@ -1,4 +1,4 @@ -import {ChangeDetectorRef, Component, ElementRef, EventEmitter, HostListener, Input, Output, ViewChild} from '@angular/core'; +import {ChangeDetectorRef, Component, ElementRef, Input, ViewChild} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {Meta, Title} from '@angular/platform-browser'; @@ -18,8 +18,7 @@ import {IndexInfoService} from "../../utils/indexInfo.service"; import {Identifier, StringUtils} from "../../utils/string-utils.class"; import {properties} from "../../../../environments/environment"; import {ISVocabulariesService} from "../../utils/staticAutoComplete/ISVocabularies.service"; -import {forkJoin, Observable, Subscription, zip} from "rxjs"; -import {AnnotationComponent} from "../annotation/annotation.component"; +import {Subscription} from "rxjs"; import {ParsingFunctions} from "../landing-utils/parsingFunctions.class"; import {ConnectHelper} from "../../connect/connectHelper"; import {UserManagementService} from "../../services/user-management.service"; @@ -383,7 +382,8 @@ export class ResultLandingComponent { subscription.unsubscribe(); } else if (subscription instanceof Function) { subscription(); - } else if (subscription instanceof (ResizeObserver || IntersectionObserver)) { + } else if ((typeof ResizeObserver != 'undefined' && subscription instanceof ResizeObserver) || + (typeof IntersectionObserver != 'undefined' && subscription instanceof IntersectionObserver)) { subscription.disconnect(); } }); diff --git a/utils/modal/full-screen-modal/full-screen-modal.component.ts b/utils/modal/full-screen-modal/full-screen-modal.component.ts index fe27d429..f3bb60c9 100644 --- a/utils/modal/full-screen-modal/full-screen-modal.component.ts +++ b/utils/modal/full-screen-modal/full-screen-modal.component.ts @@ -76,8 +76,6 @@ export class FullScreenModalComponent implements AfterViewInit, OnDestroy { @ViewChild('modal') modal: ElementRef; @ViewChild('header') header: ElementRef; @ViewChild('body') body: ElementRef; - observer: any; - headerHeight: number; bodyHeight: number; private subscriptions: any[] = []; @@ -99,12 +97,13 @@ export class FullScreenModalComponent implements AfterViewInit, OnDestroy { ngAfterViewInit() { if(typeof window !== "undefined") { - this.observer = new ResizeObserver(entries => { + let observer = new ResizeObserver(entries => { for (let entry of entries) { this.changeHeight(); } }); - this.observer.observe(this.header.nativeElement); + observer.observe(this.header.nativeElement); + this.subscriptions.push(observer); } } @@ -117,9 +116,6 @@ export class FullScreenModalComponent implements AfterViewInit, OnDestroy { } ngOnDestroy() { - if(this.observer && this.observer instanceof ResizeObserver) { - this.observer.disconnect(); - } if(typeof document !== "undefined") { const element = document.getElementById("modal-container"); for (let i = element.childNodes.length - 1; i >= 0; --i) { @@ -132,8 +128,10 @@ export class FullScreenModalComponent implements AfterViewInit, OnDestroy { this.subscriptions.forEach(subscription => { if(subscription instanceof Subscription) { subscription.unsubscribe(); + } else if(typeof ResizeObserver != 'undefined' && subscription instanceof ResizeObserver) { + subscription.disconnect(); } - }) + }); } get isOpen() {