From f5bf883de9b3bb47aadf887a59cda987a0f0ea1d Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Tue, 28 Nov 2023 18:05:18 +0900 Subject: [PATCH] [about] fix auto scroll to chad/whale --- .../app/components/about/about.component.html | 2 +- .../app/components/about/about.component.ts | 23 +++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/components/about/about.component.html b/frontend/src/app/components/about/about.component.html index a4cc51f90..747430343 100644 --- a/frontend/src/app/components/about/about.component.html +++ b/frontend/src/app/components/about/about.component.html @@ -197,7 +197,7 @@ -
+

Whale Sponsors

diff --git a/frontend/src/app/components/about/about.component.ts b/frontend/src/app/components/about/about.component.ts index 8aa0422e8..c6f6f3632 100644 --- a/frontend/src/app/components/about/about.component.ts +++ b/frontend/src/app/components/about/about.component.ts @@ -47,8 +47,13 @@ export class AboutComponent implements OnInit { this.websocketService.want(['blocks']); this.profiles$ = this.apiService.getAboutPageProfiles$().pipe( - tap(() => { - this.goToAnchor() + tap((profiles: any) => { + const scrollToSponsors = this.route.snapshot.fragment === 'community-sponsors'; + if (scrollToSponsors && !profiles?.whales?.length && !profiles?.chads?.length) { + return; + } else { + this.goToAnchor(scrollToSponsors) + } }), share(), ) @@ -83,11 +88,19 @@ export class AboutComponent implements OnInit { this.goToAnchor(); } - goToAnchor() { + goToAnchor(scrollToSponsor = false) { + if (!scrollToSponsor) { + return; + } setTimeout(() => { if (this.route.snapshot.fragment) { - if (this.document.getElementById(this.route.snapshot.fragment)) { - this.document.getElementById(this.route.snapshot.fragment).scrollIntoView({behavior: 'smooth'}); + const el = scrollToSponsor ? this.document.getElementById('community-sponsors-anchor') : this.document.getElementById(this.route.snapshot.fragment); + if (el) { + if (scrollToSponsor) { + el.scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'}); + } else { + el.scrollIntoView({behavior: 'smooth'}); + } } } }, 1);