From be5eb9ef707130e5299e5529a9cb67544a5afcea Mon Sep 17 00:00:00 2001 From: Mononaut Date: Mon, 8 Apr 2024 08:26:45 +0000 Subject: [PATCH] Fix tx autoscroll --- .../accelerate-preview.component.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts index 008415c46..29358e611 100644 --- a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts +++ b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts @@ -85,7 +85,10 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges private cd: ChangeDetectorRef ) { if (this.stateService.ref === 'https://cash.app/') { + this.paymentType = 'cashapp'; this.insertSquare(); + } else { + this.paymentType = 'bitcoin'; } } @@ -104,16 +107,17 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges } else { this.paymentType = 'bitcoin'; } - this.onScroll(); } 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'); } } ngAfterViewInit() { + this.onScroll(); + if (this.paymentType === 'cashapp') { this.showSpinner = true; } @@ -183,6 +187,10 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges } else { 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 onScroll() { + if (this.estimate && this.user && !this.cashappCTA?.nativeElement) { + setTimeout(() => { + this.onScroll(); + }, 200); + return; + } if (!this.cashappCTA?.nativeElement || this.paymentType !== 'cashapp' || !this.isMobile) { return; }