Fixed keyboard navigation bugs.
This commit is contained in:
@@ -54,6 +54,28 @@ export class BlockchainBlocksComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
this.moveArrowToPosition(false);
|
||||
});
|
||||
|
||||
this.stateService.keyNavigation$.subscribe((event) => {
|
||||
if (!this.markHeight) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.key === 'ArrowRight') {
|
||||
const blockindex = this.blocks.findIndex((b) => b.height === this.markHeight);
|
||||
if (this.blocks[blockindex + 1]) {
|
||||
this.router.navigate([(this.network ? '/' + this.network : '') + '/block/',
|
||||
this.blocks[blockindex + 1].id], { state: { data: { block: this.blocks[blockindex + 1] } } });
|
||||
}
|
||||
} else if (event.key === 'ArrowLeft') {
|
||||
const blockindex = this.blocks.findIndex((b) => b.height === this.markHeight);
|
||||
if (blockindex === 0) {
|
||||
this.router.navigate([(this.network ? '/' + this.network : '') + '/mempool-block/', '0']);
|
||||
} else {
|
||||
this.router.navigate([(this.network ? '/' + this.network : '') + '/block/',
|
||||
this.blocks[blockindex - 1].id], { state: { data: { block: this.blocks[blockindex - 1] }}});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
@@ -61,28 +83,6 @@ export class BlockchainBlocksComponent implements OnInit, OnDestroy {
|
||||
clearInterval(this.interval);
|
||||
}
|
||||
|
||||
@HostListener('document:keydown', ['$event'])
|
||||
handleKeyboardEvents(event: KeyboardEvent) {
|
||||
if (!this.markHeight) {
|
||||
return;
|
||||
}
|
||||
if (event.key === 'ArrowRight') {
|
||||
const blockindex = this.blocks.findIndex((b) => b.height === this.markHeight);
|
||||
if (this.blocks[blockindex + 1]) {
|
||||
this.router.navigate([(this.network ? '/' + this.network : '') + '/block/',
|
||||
this.blocks[blockindex + 1].id], { state: { data: { block: this.blocks[blockindex + 1] } } });
|
||||
}
|
||||
} else if (event.key === 'ArrowLeft') {
|
||||
const blockindex = this.blocks.findIndex((b) => b.height === this.markHeight);
|
||||
if (blockindex === 0) {
|
||||
this.router.navigate([(this.network ? '/' + this.network : '') + '/mempool-block/', '0']);
|
||||
} else {
|
||||
this.router.navigate([(this.network ? '/' + this.network : '') + '/block/',
|
||||
this.blocks[blockindex - 1].id], { state: { data: { block: this.blocks[blockindex - 1] }}});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
moveArrowToPosition(animate: boolean) {
|
||||
if (!this.markHeight) {
|
||||
this.arrowVisible = false;
|
||||
|
||||
Reference in New Issue
Block a user