Merge pull request #3007 from mempool/mononaut/mobile-chain-jumping

Fix blockchain scroll jumping on resize on mobile
This commit is contained in:
softsimon 2023-02-23 15:09:10 +04:00 committed by GitHub
commit a7fb62ce4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -123,7 +123,7 @@ export class StartComponent implements OnInit, OnDestroy {
this.minScrollWidth = this.firstPageWidth + (this.pageWidth * 2); this.minScrollWidth = this.firstPageWidth + (this.pageWidth * 2);
if (firstVisibleBlock != null) { if (firstVisibleBlock != null) {
this.scrollToBlock(firstVisibleBlock, offset); this.scrollToBlock(firstVisibleBlock, offset + (this.isMobile ? this.blockWidth : 0));
} else { } else {
this.updatePages(); this.updatePages();
} }
@ -178,8 +178,10 @@ export class StartComponent implements OnInit, OnDestroy {
setTimeout(() => { this.scrollToBlock(height, blockOffset); }, 50); setTimeout(() => { this.scrollToBlock(height, blockOffset); }, 50);
return; return;
} }
const targetHeight = this.isMobile ? height - 1 : height; if (this.isMobile) {
const viewingPageIndex = this.getPageIndexOf(targetHeight); blockOffset -= this.blockWidth;
}
const viewingPageIndex = this.getPageIndexOf(height);
const pages = []; const pages = [];
this.pageIndex = Math.max(viewingPageIndex - 1, 0); this.pageIndex = Math.max(viewingPageIndex - 1, 0);
let viewingPage = this.getPageAt(viewingPageIndex); let viewingPage = this.getPageAt(viewingPageIndex);
@ -189,7 +191,7 @@ export class StartComponent implements OnInit, OnDestroy {
viewingPage = this.getPageAt(viewingPageIndex); viewingPage = this.getPageAt(viewingPageIndex);
} }
const left = viewingPage.offset - this.getConvertedScrollOffset(); const left = viewingPage.offset - this.getConvertedScrollOffset();
const blockIndex = viewingPage.height - targetHeight; const blockIndex = viewingPage.height - height;
const targetOffset = (this.blockWidth * blockIndex) + left; const targetOffset = (this.blockWidth * blockIndex) + left;
let deltaOffset = targetOffset - blockOffset; let deltaOffset = targetOffset - blockOffset;