[ADF-4937] Viewer - Drag and Drop is not operable with keyboard alone (#5126)

* add keyboard event logic

* tests

* fix outline visibility
This commit is contained in:
Cilibiu Bogdan
2019-10-09 19:52:26 +03:00
committed by Denys Vuika
parent e0b1a3fe03
commit 8da16ea1a7
4 changed files with 64 additions and 1 deletions

View File

@@ -55,6 +55,7 @@ export class ImgViewerComponent implements OnInit, OnChanges, OnDestroy {
scaleY: number = 1.0;
offsetX: number = 0;
offsetY: number = 0;
step: number = 4;
isDragged: boolean = false;
private drag = { x: 0, y: 0 };
@@ -108,6 +109,27 @@ export class ImgViewerComponent implements OnInit, OnChanges, OnDestroy {
}
}
onKeyDown(event: KeyboardEvent) {
const scaleX = (this.scaleX !== 0 ? this.scaleX : 1.0);
const scaleY = (this.scaleY !== 0 ? this.scaleY : 1.0);
if (event.key === 'ArrowDown') {
this.offsetY += (this.step / scaleY);
}
if (event.key === 'ArrowUp') {
this.offsetY -= (this.step / scaleY);
}
if (event.key === 'ArrowRight') {
this.offsetX += (this.step / scaleX);
}
if (event.key === 'ArrowLeft') {
this.offsetX -= (this.step / scaleX);
}
}
onMouseDown(event: MouseEvent) {
event.preventDefault();
this.isDragged = true;