Optimize setBar event and remove unnecessary class manipulation in artplayer-plugin-chapter

This commit is contained in:
Harvey Zack committed 2024-06-03 10:04:09 +08:00
1 parent f3db438d6b
commit 5160dcabca
3 files changed
+6 -9

No files matched your search

@@ -42,6 +42,8 @@ export default function artplayerPluginChapter(option = {}) {
}
function update(chapters = []) {
removeClass($player, 'artplayer-plugin-chapter');
if (!Array.isArray(chapters)) return;
if (!chapters.length) return;
if (!art.duration) return;
@@ -108,12 +110,7 @@ export default function artplayerPluginChapter(option = {}) {
};
});
if ($chapters.length) {
addClass($player, 'artplayer-plugin-chapter');
} else {
removeClass($player, 'artplayer-plugin-chapter');
}
addClass($player, 'artplayer-plugin-chapter');
art.emit('setBar', 'loaded', art.loaded || 0);
}