mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-24 14:41:20 -08:00
优化自动隐藏controls
This commit is contained in:
1 parent
ce56c680da
commit
be3d97bf75
6 files changed
+36
-75
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { errorHandle, addClass, debounce, removeClass } from '../utils';
|
||||
import { errorHandle, addClass, removeClass } from '../utils';
|
||||
import Component from '../utils/component';
|
||||
import fullscreen from './fullscreen';
|
||||
import fullscreenWeb from './fullscreenWeb';
|
||||
@@ -26,15 +26,22 @@ export default class Control extends Component {
|
||||
template: { $player },
|
||||
} = art;
|
||||
|
||||
this.delayHide = debounce(() => {
|
||||
if (player.playing && this.show) {
|
||||
this.mouseMoveTime = Date.now();
|
||||
|
||||
art.on('mousemove', () => {
|
||||
this.show = true;
|
||||
removeClass($player, 'art-hide-cursor');
|
||||
addClass($player, 'art-hover');
|
||||
this.mouseMoveTime = Date.now();
|
||||
});
|
||||
|
||||
art.on('video:timeupdate', () => {
|
||||
if (player.playing && this.show && Date.now() - this.mouseMoveTime >= 3000) {
|
||||
this.show = false;
|
||||
addClass($player, 'art-hide-cursor');
|
||||
removeClass($player, 'art-hover');
|
||||
this.show = false;
|
||||
}
|
||||
}, 3000);
|
||||
|
||||
this.cancelDelayHide = this.delayHide.clearTimeout;
|
||||
});
|
||||
|
||||
art.once('ready', () => {
|
||||
this.add(
|
||||
|
||||
Reference in new issue
Block a user