Optimize setBar event and add lazy loading for thumbnails in artplayer-plugin-chapter

This commit is contained in:
Harvey Zack committed 2024-06-02 22:23:22 +08:00
1 parent 0e58ce8cd9
commit aaa5ef310e
5 files changed
+48 -37

No files matched your search

+13 -8
View File
@@ -64,9 +64,7 @@ export default function artplayerPluginChapter({ chapters = [] }) {
}
});
art.proxy($progress, 'mousemove', (event) => {
if (!$chapters.length) return;
function showTitle(event) {
const $target = event.target.closest('.art-chapter');
if ($target) {
setStyle($title, 'display', 'flex');
@@ -85,12 +83,19 @@ export default function artplayerPluginChapter({ chapters = [] }) {
} else {
setStyle($title, 'display', 'none');
}
});
}
art.proxy($progress, 'mouseleave', () => {
if (!$chapters.length) return;
setStyle($title, 'display', 'none');
});
if (!isMobile) {
art.proxy($progress, 'mousemove', (event) => {
if (!$chapters.length) return;
showTitle(event);
});
art.proxy($progress, 'mouseleave', () => {
if (!$chapters.length) return;
setStyle($title, 'display', 'none');
});
}
art.on('video:loadedmetadata', () => {
$control.innerText = '';