mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-26 00:31:20 -08:00
Refactor thumbnailsMix to add hover event handling
This commit is contained in:
1 parent
8481bddba1
commit
406d71b53c
3 files changed
+273
-244
No files matched your search
@@ -2,6 +2,7 @@ import { def, setStyle, isMobile, loadImg } from '../utils';
|
||||
|
||||
export default function thumbnailsMix(art) {
|
||||
const {
|
||||
events,
|
||||
option,
|
||||
template: { $progress, $video },
|
||||
} = art;
|
||||
@@ -10,6 +11,7 @@ export default function thumbnailsMix(art) {
|
||||
let image = null;
|
||||
let loading = false;
|
||||
let isLoad = false;
|
||||
let isHover = false;
|
||||
|
||||
function reset() {
|
||||
clearTimeout(timer);
|
||||
@@ -43,6 +45,16 @@ export default function thumbnailsMix(art) {
|
||||
}
|
||||
}
|
||||
|
||||
events.hover(
|
||||
$progress,
|
||||
() => {
|
||||
isHover = true;
|
||||
},
|
||||
() => {
|
||||
isHover = false;
|
||||
},
|
||||
);
|
||||
|
||||
art.on('setBar', async (type, percentage, event) => {
|
||||
const $thumbnails = art.controls?.thumbnails;
|
||||
const { url, scale } = option.thumbnails;
|
||||
@@ -57,7 +69,7 @@ export default function thumbnailsMix(art) {
|
||||
isLoad = true;
|
||||
}
|
||||
|
||||
if (!isLoad) return;
|
||||
if (!isLoad || !isHover) return;
|
||||
|
||||
const width = $progress.clientWidth * percentage;
|
||||
setStyle($thumbnails, 'display', 'flex');
|
||||
|
||||
Reference in new issue
Block a user