From 9f15e9a1d76a9a88f622a0890ac8e9e9a8e93415 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Wed, 1 Feb 2023 11:52:00 -0600 Subject: [PATCH] Fix blockchain scroll jumping on resize on mobile --- frontend/src/app/components/start/start.component.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/components/start/start.component.ts b/frontend/src/app/components/start/start.component.ts index d29372d97..20492669d 100644 --- a/frontend/src/app/components/start/start.component.ts +++ b/frontend/src/app/components/start/start.component.ts @@ -123,7 +123,7 @@ export class StartComponent implements OnInit, OnDestroy { this.minScrollWidth = this.firstPageWidth + (this.pageWidth * 2); if (firstVisibleBlock != null) { - this.scrollToBlock(firstVisibleBlock, offset); + this.scrollToBlock(firstVisibleBlock, offset + (this.isMobile ? this.blockWidth : 0)); } else { this.updatePages(); } @@ -178,8 +178,10 @@ export class StartComponent implements OnInit, OnDestroy { setTimeout(() => { this.scrollToBlock(height, blockOffset); }, 50); return; } - const targetHeight = this.isMobile ? height - 1 : height; - const viewingPageIndex = this.getPageIndexOf(targetHeight); + if (this.isMobile) { + blockOffset -= this.blockWidth; + } + const viewingPageIndex = this.getPageIndexOf(height); const pages = []; this.pageIndex = Math.max(viewingPageIndex - 1, 0); let viewingPage = this.getPageAt(viewingPageIndex); @@ -189,7 +191,7 @@ export class StartComponent implements OnInit, OnDestroy { viewingPage = this.getPageAt(viewingPageIndex); } const left = viewingPage.offset - this.getConvertedScrollOffset(); - const blockIndex = viewingPage.height - targetHeight; + const blockIndex = viewingPage.height - height; const targetOffset = (this.blockWidth * blockIndex) + left; let deltaOffset = targetOffset - blockOffset;