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

@@ -179,6 +179,7 @@ function artplayerPluginChapter(option = {}) {
} else setStyle($title, "display", "none");
}
function update(chapters = []) {
removeClass($player, "artplayer-plugin-chapter");
if (!Array.isArray(chapters)) return;
if (!chapters.length) return;
if (!art.duration) return;
@@ -224,8 +225,7 @@ function artplayerPluginChapter(option = {}) {
$played: query(".art-progress-played", $chapter)
};
});
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);
}
art.on("setBar", (type, percentage, event)=>{