Merge pull request #4920 from mempool/mononaut/fix-tx-autoscroll

Fix tx autoscroll
This commit is contained in:
wiz 2024-04-08 17:59:54 +09:00 committed by GitHub
commit e477f09cd5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -85,7 +85,10 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges
private cd: ChangeDetectorRef private cd: ChangeDetectorRef
) { ) {
if (this.stateService.ref === 'https://cash.app/') { if (this.stateService.ref === 'https://cash.app/') {
this.paymentType = 'cashapp';
this.insertSquare(); this.insertSquare();
} else {
this.paymentType = 'bitcoin';
} }
} }
@ -104,16 +107,17 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges
} else { } else {
this.paymentType = 'bitcoin'; this.paymentType = 'bitcoin';
} }
this.onScroll();
} }
ngOnChanges(changes: SimpleChanges): void { ngOnChanges(changes: SimpleChanges): void {
if (changes.scrollEvent && this.paymentType !== 'cashapp') { if (changes.scrollEvent && this.paymentType !== 'cashapp' && this.stateService.ref !== 'https://cash.app/') {
this.scrollToPreview('acceleratePreviewAnchor', 'start'); this.scrollToPreview('acceleratePreviewAnchor', 'start');
} }
} }
ngAfterViewInit() { ngAfterViewInit() {
this.onScroll();
if (this.paymentType === 'cashapp') { if (this.paymentType === 'cashapp') {
this.showSpinner = true; this.showSpinner = true;
} }
@ -183,6 +187,10 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges
} else { } else {
this.scrollToPreview('acceleratePreviewAnchor', 'start'); this.scrollToPreview('acceleratePreviewAnchor', 'start');
} }
setTimeout(() => {
this.onScroll();
}, 100);
} }
} }
}), }),
@ -390,6 +398,12 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges
@HostListener('window:scroll', ['$event']) // for window scroll events @HostListener('window:scroll', ['$event']) // for window scroll events
onScroll() { onScroll() {
if (this.estimate && this.user && !this.cashappCTA?.nativeElement) {
setTimeout(() => {
this.onScroll();
}, 200);
return;
}
if (!this.cashappCTA?.nativeElement || this.paymentType !== 'cashapp' || !this.isMobile) { if (!this.cashappCTA?.nativeElement || this.paymentType !== 'cashapp' || !this.isMobile) {
return; return;
} }