mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-28 02:01:20 -08:00
add attrMix.js
This commit is contained in:
1 parent
1438ce5e82
commit
938e8718bc
12 files changed
+268
-232
No files matched your search
@@ -1,5 +1,3 @@
|
||||
import { errorHandle } from './utils';
|
||||
|
||||
export default class Hotkey {
|
||||
constructor(art) {
|
||||
this.keys = {};
|
||||
@@ -56,8 +54,6 @@ export default class Hotkey {
|
||||
}
|
||||
|
||||
add(key, event) {
|
||||
errorHandle(typeof key === 'number', 'The Hotkey.add() first parameter is not a number');
|
||||
errorHandle(typeof event === 'function', 'The Hotkey.add() second parameter is not a function');
|
||||
if (this.keys[key]) {
|
||||
this.keys[key].push(event);
|
||||
} else {
|
||||
@@ -65,4 +61,13 @@ export default class Hotkey {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
remove(key, event) {
|
||||
if (this.keys[key]) {
|
||||
const index = this.keys[key].indexOf(event);
|
||||
if (index !== -1) {
|
||||
this.keys[key].splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user