Fix key bind animation side effect

This commit is contained in:
Farkas József
2016-12-14 22:48:18 +01:00
parent 42686f4221
commit 5e7e0c4933
9 changed files with 22 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
<svg-keyboard *ngFor="let layer of layers; let index = index; trackBy: trackKeyboard"
[@layerState]="layerAnimationState[index]"
[moduleConfig]="layer.modules"
[keybindAnimationEnabled]="keybindAnimationEnabled"
(keyClick)="keyClick.emit($event)"
(keyHover)="keyHover.emit($event)">
</svg-keyboard>

Before

Width:  |  Height:  |  Size: 334 B

After

Width:  |  Height:  |  Size: 408 B

View File

@@ -78,6 +78,7 @@ type AnimationKeyboard =
export class KeyboardSliderComponent implements OnChanges {
@Input() layers: Layer[];
@Input() currentLayer: number;
@Input() keybindAnimationEnabled: boolean;
@Output() keyClick = new EventEmitter();
@Output() keyHover = new EventEmitter();

View File

@@ -3,6 +3,7 @@
<svg:g svg-module *ngFor="let module of modules; let i = index"
[coverages]="module.coverages"
[keyboardKeys]="module.keyboardKeys"
[keybindAnimationEnabled]="keybindAnimationEnabled"
[attr.transform]="module.attributes.transform"
[keyActions]="moduleConfig[i].keyActions"
(keyClick)="onKeyClick(i, $event.index, $event.keyTarget)"

Before

Width:  |  Height:  |  Size: 677 B

After

Width:  |  Height:  |  Size: 745 B

View File

@@ -10,6 +10,7 @@ import { SvgModule } from '../module';
})
export class SvgKeyboardComponent implements OnInit {
@Input() moduleConfig: Module[];
@Input() keybindAnimationEnabled: boolean;
@Output() keyClick = new EventEmitter();
@Output() keyHover = new EventEmitter();

View File

@@ -59,6 +59,7 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
@Input() height: number;
@Input() width: number;
@Input() keyAction: KeyAction;
@Input() keybindAnimationEnabled: boolean;
@Output() keyClick = new EventEmitter();
enumLabelTypes = LabelTypes;
@@ -86,7 +87,9 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
/* tslint:disable:no-string-literal */
if (changes['keyAction']) {
this.setLabels();
this.animation = 'active';
if (this.keybindAnimationEnabled) {
this.animation = 'active';
}
}
/* tslint:enable:no-string-literal */
}

View File

@@ -5,6 +5,7 @@
[width]="key.width" [height]="key.height"
[attr.transform]="'translate(' + key.x + ' ' + key.y + ')'"
[keyAction]="keyActions[i]"
[keybindAnimationEnabled]="keybindAnimationEnabled"
(keyClick)="onKeyClick(i, $event)"
(mouseenter)="onKeyHover(i, $event, true)"
(mouseleave)="onKeyHover(i, $event, false)"

Before

Width:  |  Height:  |  Size: 496 B

After

Width:  |  Height:  |  Size: 556 B

View File

@@ -13,6 +13,7 @@ export class SvgModuleComponent {
@Input() coverages: any[];
@Input() keyboardKeys: SvgKeyboardKey[];
@Input() keyActions: KeyAction[];
@Input() keybindAnimationEnabled: boolean;
@Output() keyClick = new EventEmitter();
@Output() keyHover = new EventEmitter();

View File

@@ -2,6 +2,7 @@
<layers [class.disabled]="popoverShown" (select)="selectLayer($event.index)" [current]="currentLayer"></layers>
<keyboard-slider [layers]="layers"
[currentLayer]="currentLayer"
[keybindAnimationEnabled]="keybindAnimationEnabled"
(keyClick)="onKeyClick($event.moduleId, $event.keyId, $event.keyTarget)"
(keyHover)="onKeyHover($event.moduleId, $event.event, $event.over, $event.keyId)"></keyboard-slider>
<popover [visible]="popoverShown" [keyPosition]="keyPosition" [wrapPosition]="wrapPosition" [defaultKeyAction]="popoverInitKeyAction" [currentKeymap]="keymap" (cancel)="hidePopover()" (remap)="onRemap($event)"></popover>

View File

@@ -46,6 +46,7 @@ export class SvgKeyboardWrapComponent implements OnInit, OnChanges {
private popoverShown: boolean;
private keyEditConfig: { moduleId: number, keyId: number };
private popoverInitKeyAction: KeyAction;
private keybindAnimationEnabled: boolean;
private currentLayer: number = 0;
private tooltipData: { posTop: number, posLeft: number, content: { name: string, value: string }[], show: boolean };
private layers: Layer[];
@@ -89,13 +90,18 @@ export class SvgKeyboardWrapComponent implements OnInit, OnChanges {
}
ngOnChanges(changes: SimpleChanges) {
if (changes['keymap'].previousValue.abbreviation !== changes['keymap'].currentValue.abbreviation) {
this.layers = this.keymap.layers;
this.currentLayer = 0;
this.popoverShown = false;
} else if (changes['keymap']) {
const keymapChanges = changes['keymap'];
if (keymapChanges) {
this.popoverShown = false;
if (keymapChanges.previousValue.abbreviation !== keymapChanges.currentValue.abbreviation) {
this.layers = this.keymap.layers;
this.currentLayer = 0;
this.keybindAnimationEnabled = keymapChanges.isFirstChange();
} else {
this.keybindAnimationEnabled = true;
}
}
}
onKeyClick(moduleId: number, keyId: number, keyTarget: HTMLElement): void {