Merge branch 'nymkappa/about-page-empty-anchor' into nymkappa/fix-one-bug-add-two-more

This commit is contained in:
nymkappa 2023-12-03 15:17:04 +09:00
commit 181e816c1a
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04
2 changed files with 19 additions and 6 deletions

View File

@ -182,7 +182,7 @@
</div> </div>
<ng-container *ngIf="officialMempoolSpace"> <ng-container *ngIf="officialMempoolSpace">
<div *ngIf="profiles$ | async as profiles" id="community-sponsors"> <div *ngIf="profiles$ | async as profiles" id="community-sponsors-anchor">
<div class="community-sponsor" style="margin-bottom: 68px" *ngIf="profiles.whales.length > 0"> <div class="community-sponsor" style="margin-bottom: 68px" *ngIf="profiles.whales.length > 0">
<h3 i18n="about.sponsors.withHeart">Whale Sponsors</h3> <h3 i18n="about.sponsors.withHeart">Whale Sponsors</h3>
<div class="wrapper"> <div class="wrapper">

View File

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