Make Esc close popover

This commit is contained in:
Farkas József
2016-12-26 21:54:14 +01:00
committed by József Farkas
parent 28159ec9c0
commit 0081e3e337
4 changed files with 22 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
import {
Component, ElementRef, EventEmitter, Input, OnChanges, Output, SimpleChanges, ViewChild, animate, keyframes,
state, style, transition, trigger
Component, ElementRef, EventEmitter, HostListener, Input, OnChanges, Output, SimpleChanges, ViewChild,
animate, keyframes, state, style, transition, trigger
} from '@angular/core';
import { Store } from '@ngrx/store';
@@ -49,7 +49,7 @@ enum TabName {
transition('opened => closed', [
animate('200ms ease-out', keyframes([
style({ transform: 'translateY(0)', visibility: 'visible', opacity: 1, offset: 0 }),
style({ transform: 'translateY(30px)', visibility: 'hidden', opacity: 0 , offset: 1 })
style({ transform: 'translateY(30px)', visibility: 'hidden', opacity: 0, offset: 1 })
]))
]),
transition('closed => opened', [
@@ -143,6 +143,10 @@ export class PopoverComponent implements OnChanges {
}
}
@HostListener('keydown.escape') onEscape(): void {
this.cancel.emit();
}
selectTab(tab: TabName): void {
this.activeTab = tab;
}
@@ -156,7 +160,7 @@ export class PopoverComponent implements OnChanges {
const popover: HTMLElement = this.popoverHost.nativeElement;
let newLeft: number = this.keyPosition.left + (this.keyPosition.width / 2);
this.leftArrow = newLeft < offsetLeft;
this.leftArrow = newLeft < offsetLeft;
this.rightArrow = (newLeft + popover.offsetWidth) > offsetLeft + this.wrapPosition.width;
if (this.leftArrow) {

View File

@@ -32,6 +32,7 @@ export class CaptureKeystrokeButtonComponent {
if (this.record) {
e.preventDefault();
e.stopPropagation();
this.first = false;
if (this.captureService.hasMap(code)) {