mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-21 12:41:20 -08:00
添加自动隐藏光标
This commit is contained in:
1 parent
617fd9681e
commit
d9fd20bdf3
14 files changed
+127
-27
No files matched your search
@@ -1,14 +1,38 @@
|
||||
import { debounce } from './utils';
|
||||
|
||||
export default class Events {
|
||||
constructor(art) {
|
||||
this.art = art;
|
||||
this.destroyEvents = [];
|
||||
this.proxy = this.proxy.bind(this);
|
||||
this.hover = this.hover.bind(this);
|
||||
this.init();
|
||||
}
|
||||
|
||||
init() {
|
||||
const { refs: { $player } } = this.art;
|
||||
this.hover($player, () => {
|
||||
$player.classList.add('artplayer-hover');
|
||||
this.art.emit('hoverenter');
|
||||
}, () => {
|
||||
$player.classList.remove('artplayer-hover');
|
||||
$player.classList.remove('artplayer-hide-cursor');
|
||||
this.art.emit('hoverleave');
|
||||
});
|
||||
|
||||
const hideCursor = debounce(() => {
|
||||
$player.classList.add('artplayer-hide-cursor');
|
||||
}, 5000);
|
||||
this.proxy($player, 'mousemove', () => {
|
||||
$player.classList.remove('artplayer-hide-cursor');
|
||||
hideCursor();
|
||||
});
|
||||
}
|
||||
|
||||
proxy(target, name, callback, option = {}) {
|
||||
if (Array.isArray(name)) {
|
||||
name.forEach(item => this.proxy(target, item, callback, option));
|
||||
return;
|
||||
}
|
||||
|
||||
target.addEventListener(name, callback, option);
|
||||
|
||||
Reference in new issue
Block a user