mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-21 02:48:00 +00:00
.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
.stroke(*ngFor='let stroke of model')
|
.stroke(*ngFor='let stroke of model')
|
||||||
.key-container(
|
.key-container(
|
||||||
*ngFor='let key of splitKeys(stroke); let isLast = last; trackBy: key',
|
*ngFor='let key of splitKeys(stroke); let isLast = last; trackBy: key',
|
||||||
@animateKey
|
[@animateKey]='animate ? "in" : ""'
|
||||||
)
|
)
|
||||||
.key {{key}}
|
.key {{key}}
|
||||||
.plus(*ngIf='!isLast') +
|
.plus(*ngIf='!isLast') +
|
||||||
|
@@ -2,31 +2,34 @@ import { Component, Input, ChangeDetectionStrategy, trigger, style, animate, tra
|
|||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'hotkey-display',
|
selector: 'hotkey-display',
|
||||||
template: require('./hotkeyDisplay.pug'),
|
template: require('./hotkeyDisplay.pug'),
|
||||||
styles: [require('./hotkeyDisplay.less')],
|
styles: [require('./hotkeyDisplay.less')],
|
||||||
//changeDetection: ChangeDetectionStrategy.OnPush,
|
//changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
animations: [
|
animations: [
|
||||||
trigger('animateKey', [
|
trigger('animateKey', [
|
||||||
state('in', style({
|
transition('void => in', [
|
||||||
'transform': 'translateX(0)',
|
style({
|
||||||
'opacity': '1',
|
transform: 'translateX(25px)',
|
||||||
})),
|
opacity: '0',
|
||||||
transition(':enter', [
|
}),
|
||||||
style({
|
animate('250ms ease-out', style({
|
||||||
'transform': 'translateX(25px)',
|
transform: 'translateX(0)',
|
||||||
'opacity': '0',
|
opacity: '1',
|
||||||
}),
|
}))
|
||||||
animate('250ms ease-out')
|
]),
|
||||||
]),
|
transition('in => void', [
|
||||||
transition(':leave', [
|
style({
|
||||||
animate('250ms ease-in', style({
|
transform: 'translateX(0)',
|
||||||
'transform': 'translateX(25px)',
|
opacity: '1',
|
||||||
'opacity': '0',
|
}),
|
||||||
}))
|
animate('250ms ease-in', style({
|
||||||
])
|
transform: 'translateX(25px)',
|
||||||
])
|
opacity: '0',
|
||||||
]
|
}))
|
||||||
|
])
|
||||||
|
])
|
||||||
|
]
|
||||||
})
|
})
|
||||||
export class HotkeyDisplayComponent {
|
export class HotkeyDisplayComponent {
|
||||||
splitKeys(keys: string): string[] {
|
splitKeys(keys: string): string[] {
|
||||||
@@ -34,4 +37,5 @@ export class HotkeyDisplayComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Input() model: string[]
|
@Input() model: string[]
|
||||||
|
@Input() animate = false
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
:host {
|
:host {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 5px 10px;
|
padding: 5px;
|
||||||
|
|
||||||
transition: 0.125s all;
|
transition: 0.125s all;
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
div.modal-body
|
div.modal-body
|
||||||
label Press the key now
|
label Press the key now
|
||||||
.input
|
.input
|
||||||
hotkey-display([model]='value')
|
hotkey-display([model]='value', [animate]='true')
|
||||||
|
|
||||||
.timeout
|
.timeout
|
||||||
div([style.width]='timeoutProgress + "%"')
|
div([style.width]='timeoutProgress + "%"')
|
||||||
|
@@ -44,9 +44,11 @@ export class HotkeyInputModalComponent {
|
|||||||
this.modalInstance.close(this.value)
|
this.modalInstance.close(this.value)
|
||||||
}
|
}
|
||||||
}, 25)
|
}, 25)
|
||||||
|
this.hotkeys.disable()
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy () {
|
ngOnDestroy () {
|
||||||
|
this.hotkeys.enable()
|
||||||
clearInterval(this.keyTimeoutInterval)
|
clearInterval(this.keyTimeoutInterval)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -57,6 +57,7 @@ export class HotkeysService {
|
|||||||
matchedHotkey = new EventEmitter<string>()
|
matchedHotkey = new EventEmitter<string>()
|
||||||
globalHotkey = new EventEmitter()
|
globalHotkey = new EventEmitter()
|
||||||
private currentKeystrokes: EventBufferEntry[] = []
|
private currentKeystrokes: EventBufferEntry[] = []
|
||||||
|
private disabledLevel = 0
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private zone: NgZone,
|
private zone: NgZone,
|
||||||
@@ -98,11 +99,13 @@ export class HotkeysService {
|
|||||||
this.currentKeystrokes.push({ event: nativeEvent, time: performance.now() })
|
this.currentKeystrokes.push({ event: nativeEvent, time: performance.now() })
|
||||||
|
|
||||||
this.zone.run(() => {
|
this.zone.run(() => {
|
||||||
let matched = this.getCurrentFullyMatchedHotkey()
|
if (this.isEnabled()) {
|
||||||
if (matched) {
|
let matched = this.getCurrentFullyMatchedHotkey()
|
||||||
console.log('Matched hotkey', matched)
|
if (matched) {
|
||||||
this.matchedHotkey.emit(matched)
|
console.log('Matched hotkey', matched)
|
||||||
this.clearCurrentKeystrokes()
|
this.matchedHotkey.emit(matched)
|
||||||
|
this.clearCurrentKeystrokes()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.key.emit(nativeEvent)
|
this.key.emit(nativeEvent)
|
||||||
})
|
})
|
||||||
@@ -179,4 +182,17 @@ export class HotkeysService {
|
|||||||
getHotkeyDescription (id: string) : HotkeyDescription {
|
getHotkeyDescription (id: string) : HotkeyDescription {
|
||||||
return HOTKEYS.filter((x) => x.id == id)[0]
|
return HOTKEYS.filter((x) => x.id == id)[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enable () {
|
||||||
|
this.disabledLevel--
|
||||||
|
}
|
||||||
|
|
||||||
|
disable () {
|
||||||
|
this.disabledLevel++
|
||||||
|
}
|
||||||
|
|
||||||
|
isEnabled () {
|
||||||
|
return this.disabledLevel == 0
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
"typings": "2.0.0",
|
"typings": "2.0.0",
|
||||||
"url-loader": "^0.5.7",
|
"url-loader": "^0.5.7",
|
||||||
"val-loader": "^0.5.0",
|
"val-loader": "^0.5.0",
|
||||||
"webpack": "2.2.0-rc.0"
|
"webpack": "2.2.0-rc.4"
|
||||||
},
|
},
|
||||||
"build": {
|
"build": {
|
||||||
"appId": "com.elements.benchmark",
|
"appId": "com.elements.benchmark",
|
||||||
|
Reference in New Issue
Block a user