mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-28 18:41:20 -08:00
提取共用方法
This commit is contained in:
1 parent
48ade99047
commit
7a84c262da
45 files changed
+242
-257
No files matched your search
@@ -1,3 +1,5 @@
|
||||
import { addClass, removeClass } from '../utils';
|
||||
|
||||
export default function hoverInit(art, events) {
|
||||
const {
|
||||
template: { $player },
|
||||
@@ -5,11 +7,11 @@ export default function hoverInit(art, events) {
|
||||
events.hover(
|
||||
$player,
|
||||
() => {
|
||||
$player.classList.add('artplayer-hover');
|
||||
addClass($player, 'artplayer-hover');
|
||||
art.emit('hoverenter');
|
||||
},
|
||||
() => {
|
||||
$player.classList.remove('artplayer-hover');
|
||||
removeClass($player, 'artplayer-hover');
|
||||
art.emit('hoverleave');
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { debounce } from '../utils';
|
||||
import { debounce, addClass, removeClass } from '../utils';
|
||||
|
||||
export default function mousemoveInitInit(art, events) {
|
||||
const {
|
||||
@@ -7,8 +7,8 @@ export default function mousemoveInitInit(art, events) {
|
||||
} = art;
|
||||
|
||||
const autoHide = debounce(() => {
|
||||
$player.classList.add('artplayer-hide-cursor');
|
||||
$player.classList.remove('artplayer-hover');
|
||||
addClass($player, 'artplayer-hide-cursor');
|
||||
removeClass($player, 'artplayer-hover');
|
||||
art.controls.show = false;
|
||||
}, 3000);
|
||||
|
||||
@@ -20,7 +20,7 @@ export default function mousemoveInitInit(art, events) {
|
||||
|
||||
events.proxy($player, 'mousemove', event => {
|
||||
autoHide.clearTimeout();
|
||||
$player.classList.remove('artplayer-hide-cursor');
|
||||
removeClass($player, 'artplayer-hide-cursor');
|
||||
art.controls.show = true;
|
||||
if (!art.player.pip && player.playing && event.target === $video) {
|
||||
autoHide();
|
||||
|
||||
Reference in new issue
Block a user