Skip to content

Commit 2f459a8

Browse files
ert78gbmondalaci
authored andcommitted
feat(agent): remove routing animation from keymaps (#468)
* feat(agent): remove routing animation from keymaps * fix(agent): stylelint warning * fix(web): Align center the keyboard in init state
1 parent 6c6e2af commit 2f459a8

File tree

1 file changed

+31
-19
lines changed

1 file changed

+31
-19
lines changed

packages/uhk-web/src/app/components/keyboard/slider/keyboard-slider.component.ts

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { Layer } from 'uhk-common';
55
import { KeyboardLayout } from '../../../keyboard/keyboard-layout.enum';
66

77
type AnimationKeyboard =
8+
'init' |
9+
'initOut' |
810
'leftIn' |
911
'leftOut' |
1012
'rightIn' |
@@ -18,6 +20,14 @@ type AnimationKeyboard =
1820
// We use 101%, because there was still a trace of the keyboard in the screen when animation was done
1921
animations: [
2022
trigger('layerState', [
23+
state('init', style({
24+
transform: 'translateX(-50%)',
25+
left: '50%'
26+
})),
27+
state('initOut', style({
28+
transform: 'translateX(0)',
29+
left: '101%'
30+
})),
2131
state('leftIn, rightIn', style({
2232
transform: 'translateX(-50%)',
2333
left: '50%'
@@ -30,34 +40,34 @@ type AnimationKeyboard =
3040
transform: 'translateX(0)',
3141
left: '101%'
3242
})),
33-
transition('leftOut => leftIn, rightOut => leftIn', [
43+
transition('initOut => leftIn, leftOut => leftIn, rightOut => leftIn', [
3444
animate('400ms ease-out', keyframes([
35-
style({ transform: 'translateX(0%)', left: '101%', offset: 0 }),
36-
style({ transform: 'translateX(-50%)', left: '50%', offset: 1 })
45+
style({transform: 'translateX(0%)', left: '101%', offset: 0}),
46+
style({transform: 'translateX(-50%)', left: '50%', offset: 1})
3747
]))
3848
]),
39-
transition('leftIn => leftOut, rightIn => leftOut', [
49+
transition('init => leftOut, leftIn => leftOut, rightIn => leftOut', [
4050
animate('400ms ease-out', keyframes([
41-
style({ transform: 'translateX(-50%)', left: '50%', offset: 0 }),
42-
style({ transform: 'translateX(-101%)', left: '0%', offset: 1 })
51+
style({transform: 'translateX(-50%)', left: '50%', offset: 0}),
52+
style({transform: 'translateX(-101%)', left: '0%', offset: 1})
4353
]))
4454
]),
4555
transition('* => rightIn', [
4656
animate('400ms ease-out', keyframes([
47-
style({ transform: 'translateX(-101%)', left: '0%', offset: 0 }),
48-
style({ transform: 'translateX(-50%)', left: '50%', offset: 1 })
57+
style({transform: 'translateX(-101%)', left: '0%', offset: 0}),
58+
style({transform: 'translateX(-50%)', left: '50%', offset: 1})
4959
]))
5060
]),
5161
transition('* => rightOut', [
5262
animate('400ms ease-out', keyframes([
53-
style({ transform: 'translateX(-50%)', left: '50%', offset: 0 }),
54-
style({ transform: 'translateX(0%)', left: '101%', offset: 1 })
63+
style({transform: 'translateX(-50%)', left: '50%', offset: 0}),
64+
style({transform: 'translateX(0%)', left: '101%', offset: 1})
5565
]))
5666
]),
5767
transition(':leave', [
5868
animate('2000ms ease-out', keyframes([
59-
style({ opacity: 1, offset: 0 }),
60-
style({ opacity: 0, offset: 1 })
69+
style({opacity: 1, offset: 0}),
70+
style({opacity: 0, offset: 1})
6171
]))
6272
])
6373
])
@@ -76,16 +86,20 @@ export class KeyboardSliderComponent implements OnChanges {
7686
@Output() capture = new EventEmitter();
7787

7888
layerAnimationState: AnimationKeyboard[];
79-
8089
ngOnChanges(changes: SimpleChanges) {
8190
if (changes['layers']) {
82-
this.layerAnimationState = this.layers.map<AnimationKeyboard>(() => 'leftOut');
83-
this.layerAnimationState[this.currentLayer] = 'leftIn';
91+
this.layerAnimationState = this.layers.map<AnimationKeyboard>(() => 'initOut');
92+
this.layerAnimationState[this.currentLayer] = 'init';
8493
}
8594
const layerChange = changes['currentLayer'];
8695
if (layerChange) {
87-
const prevValue = layerChange.isFirstChange() ? layerChange.currentValue : layerChange.previousValue;
88-
this.onLayerChange(prevValue, layerChange.currentValue);
96+
// turn off the routing navigation from non keymap route
97+
if (changes['layers']) {
98+
}
99+
else {
100+
const prevValue = layerChange.isFirstChange() ? layerChange.currentValue : layerChange.previousValue;
101+
this.onLayerChange(prevValue, layerChange.currentValue);
102+
}
89103
}
90104
}
91105

@@ -101,7 +115,5 @@ export class KeyboardSliderComponent implements OnChanges {
101115
this.layerAnimationState[oldIndex] = 'rightOut';
102116
this.layerAnimationState[index] = 'rightIn';
103117
}
104-
105118
}
106-
107119
}

0 commit comments

Comments
 (0)