Compare commits

...

3 Commits

Author SHA1 Message Date
natsoni
c6285dfa26
Merge branch 'master' into natsoni/fix-tooltip-timeline 2024-10-25 11:52:25 +02:00
softsimon
510b4adcea
Merge branch 'master' into natsoni/fix-tooltip-timeline 2024-10-04 21:59:07 -06:00
natsoni
0928d64e1e
Fix timeline tooltip on mobile 2024-09-27 18:59:23 +02:00
4 changed files with 37 additions and 21 deletions

View File

@ -1,11 +1,11 @@
<div
#tooltip
*ngIf="accelerationInfo && tooltipPosition !== null"
class="acceleration-tooltip"
[style.left]="tooltipPosition.x + 'px'"
[style.top]="tooltipPosition.y + 'px'"
[style.visibility]="accelerationInfo ? 'visible' : 'hidden'"
[style.left]="tooltipPosition?.x + 'px'"
[style.top]="tooltipPosition?.y + 'px'"
>
<table>
<table *ngIf="accelerationInfo">
<tbody>
<tr>
<td class="label" i18n="transaction.status|Transaction Status">Status</td>
@ -52,8 +52,7 @@
class="pool-logo"
[style.opacity]="accelerationInfo?.minedByPoolUniqueId && pool !== accelerationInfo?.minedByPoolUniqueId ? '0.3' : '1'"
[src]="'/resources/mining-pools/' + accelerationInfo.poolsData[pool].slug + '.svg'"
onError="this.src = '/resources/mining-pools/default.svg'"
[alt]="'Logo of ' + pool.name + ' mining pool'">
onError="this.src = '/resources/mining-pools/default.svg'">
<br *ngIf="i % 6 === 5">
</ng-container>
</td>

View File

@ -1,4 +1,4 @@
import { Component, ElementRef, ViewChild, Input, OnChanges } from '@angular/core';
import { Component, ElementRef, ViewChild, Input, OnChanges, HostListener } from '@angular/core';
@Component({
selector: 'app-acceleration-timeline-tooltip',
@ -10,6 +10,7 @@ export class AccelerationTimelineTooltipComponent implements OnChanges {
@Input() cursorPosition: { x: number, y: number };
tooltipPosition: any = null;
yScroll = window.scrollY;
@ViewChild('tooltip') tooltipElement: ElementRef<HTMLCanvasElement>;
@ -21,6 +22,9 @@ export class AccelerationTimelineTooltipComponent implements OnChanges {
let y = changes.cursorPosition.currentValue.y + 20;
if (this.tooltipElement) {
const elementBounds = this.tooltipElement.nativeElement.getBoundingClientRect();
if (this.accelerationInfo?.status !== 'seen') {
elementBounds.width = 370; // ugly hack to handle varying width due to pools logo loading
}
if ((x + elementBounds.width) > (window.innerWidth - 10)) {
x = Math.max(0, window.innerWidth - elementBounds.width - 10);
}
@ -35,4 +39,12 @@ export class AccelerationTimelineTooltipComponent implements OnChanges {
hasPoolsData(): boolean {
return Object.keys(this.accelerationInfo.poolsData).length > 0;
}
@HostListener('window:scroll', ['$event'])
onWindowScroll(): void {
if (this.tooltipPosition) {
this.tooltipPosition.y = this.tooltipPosition.y - (window.scrollY - this.yScroll);
}
this.yScroll = window.scrollY;
}
}

View File

@ -56,8 +56,8 @@
<div class="nodes">
<div class="node" [id]="'first-seen'">
<div class="seen-to-acc right"></div>
<div class="shape-border hovering" (pointerover)="onHover($event, 'seen');" (pointerout)="onBlur($event);">
<div class="shape"></div>
<div class="shape-border hovering">
<div id="step" class="shape" (pointerover)="onHover($event, 'seen');"></div>
</div>
<div class="status"><span class="badge badge-primary" i18n="transaction.first-seen|Transaction first seen">First seen</span></div>
<div class="time">
@ -78,8 +78,8 @@
} @else {
<div class="seen-to-acc right"></div>
}
<div class="shape-border hovering" (pointerover)="onHover($event, 'accelerated');" (pointerout)="onBlur($event);">
<div class="shape"></div>
<div class="shape-border hovering">
<div id="step" class="shape" (pointerover)="onHover($event, 'accelerated');"></div>
@if (!tx.status.confirmed) {
<div class="connector down loading"></div>
}
@ -111,11 +111,8 @@
} @else {
<div class="seen-to-acc left"></div>
}
<div class="shape-border"
[ngClass]="{'waiting': !tx.status.confirmed, 'hovering': tx.status.confirmed}"
(pointerover)="onHover($event, tx.status.confirmed ? 'mined' : null)"
(pointerout)="onBlur($event);">
<div class="shape"></div>
<div class="shape-border" [ngClass]="{'waiting': !tx.status.confirmed, 'hovering': tx.status.confirmed}">
<div id="step" class="shape" (pointerover)="onHover($event, tx.status.confirmed ? 'mined' : null)" ></div>
</div>
@if (tx.status.confirmed) {
<div class="status"><span class="badge badge-success" i18n="transaction.rbf.mined">Mined</span></div>

View File

@ -52,6 +52,7 @@ export class AccelerationTimelineComponent implements OnInit, OnChanges {
}
onHover(event, status: string): void {
this.tooltipPosition = { x: event.clientX, y: event.clientY };
if (status === 'seen') {
this.hoverInfo = {
status,
@ -80,12 +81,19 @@ export class AccelerationTimelineComponent implements OnInit, OnChanges {
}
}
onBlur(event): void {
this.hoverInfo = null;
}
@HostListener('pointermove', ['$event'])
onPointerMove(event) {
this.tooltipPosition = { x: event.clientX, y: event.clientY };
if (event.target.id === 'step') {
this.tooltipPosition = { x: event.clientX, y: event.clientY };
} else {
this.hoverInfo = null;
}
}
@HostListener('document:click', ['$event'])
clickAway(event) {
if (event.target.id !== 'step') {
this.hoverInfo = null;
}
}
}