scroll selected mempool block into view
This commit is contained in:
		
							parent
							
								
									d848ab4bef
								
							
						
					
					
						commit
						9d606d0006
					
				@ -40,7 +40,7 @@ export class StartComponent implements OnInit, OnDestroy {
 | 
				
			|||||||
  minScrollWidth: number;
 | 
					  minScrollWidth: number;
 | 
				
			||||||
  pageIndex: number = 0;
 | 
					  pageIndex: number = 0;
 | 
				
			||||||
  pages: any[] = [];
 | 
					  pages: any[] = [];
 | 
				
			||||||
  pendingMark: number | void = null;
 | 
					  pendingMark: number | null = null;
 | 
				
			||||||
  lastUpdate: number = 0;
 | 
					  lastUpdate: number = 0;
 | 
				
			||||||
  lastMouseX: number;
 | 
					  lastMouseX: number;
 | 
				
			||||||
  velocity: number = 0;
 | 
					  velocity: number = 0;
 | 
				
			||||||
@ -71,19 +71,29 @@ export class StartComponent implements OnInit, OnDestroy {
 | 
				
			|||||||
      this.chainTip = height;
 | 
					      this.chainTip = height;
 | 
				
			||||||
      this.tipIsSet = true;
 | 
					      this.tipIsSet = true;
 | 
				
			||||||
      this.updatePages();
 | 
					      this.updatePages();
 | 
				
			||||||
      if (this.pendingMark != null) {
 | 
					      this.applyPendingMarkArrow();
 | 
				
			||||||
        this.scrollToBlock(this.pendingMark);
 | 
					 | 
				
			||||||
        this.pendingMark = null;
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    this.markBlockSubscription = this.stateService.markBlock$.subscribe((mark) => {
 | 
					    this.markBlockSubscription = this.stateService.markBlock$.subscribe((mark) => {
 | 
				
			||||||
 | 
					      let blockHeight;
 | 
				
			||||||
      if (mark?.blockHeight != null) {
 | 
					      if (mark?.blockHeight != null) {
 | 
				
			||||||
 | 
					        blockHeight = mark.blockHeight;
 | 
				
			||||||
 | 
					      } else if (mark?.mempoolBlockIndex != null) {
 | 
				
			||||||
 | 
					        blockHeight = -1 - mark.mempoolBlockIndex;
 | 
				
			||||||
 | 
					      } else if (mark?.mempoolPosition?.block != null) {
 | 
				
			||||||
 | 
					        blockHeight = -1 - mark.mempoolPosition.block;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      if (blockHeight != null) {
 | 
				
			||||||
        if (this.tipIsSet) {
 | 
					        if (this.tipIsSet) {
 | 
				
			||||||
          if (!this.blockInViewport(mark.blockHeight)) {
 | 
					          let scrollToHeight = blockHeight;
 | 
				
			||||||
            this.scrollToBlock(mark.blockHeight);
 | 
					          if (blockHeight < 0) {
 | 
				
			||||||
 | 
					            scrollToHeight = this.chainTip - blockHeight;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        } else {
 | 
					          if (!this.blockInViewport(scrollToHeight)) {
 | 
				
			||||||
          this.pendingMark = mark.blockHeight;
 | 
					            this.scrollToBlock(scrollToHeight);
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (!this.tipIsSet || (blockHeight < 0 && !this.mempoolOffset)) {
 | 
				
			||||||
 | 
					          this.pendingMark = blockHeight;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
@ -122,6 +132,18 @@ export class StartComponent implements OnInit, OnDestroy {
 | 
				
			|||||||
    const delta = offset - this.mempoolOffset;
 | 
					    const delta = offset - this.mempoolOffset;
 | 
				
			||||||
    this.addConvertedScrollOffset(delta);
 | 
					    this.addConvertedScrollOffset(delta);
 | 
				
			||||||
    this.mempoolOffset = offset;
 | 
					    this.mempoolOffset = offset;
 | 
				
			||||||
 | 
					    this.applyPendingMarkArrow();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  applyPendingMarkArrow(): void {
 | 
				
			||||||
 | 
					    if (this.pendingMark != null) {
 | 
				
			||||||
 | 
					      if (this.pendingMark < 0) {
 | 
				
			||||||
 | 
					        this.scrollToBlock(this.chainTip - this.pendingMark);
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        this.scrollToBlock(this.pendingMark);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      this.pendingMark = null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @HostListener('window:resize', ['$event'])
 | 
					  @HostListener('window:resize', ['$event'])
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user