mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-11 13:56:15 -08:00
优化 playlist
This commit is contained in:
1 parent
328d580fb7
commit
2385128abb
2 files changed
+5
-7
No files matched your search
@@ -2,7 +2,7 @@ import './index.scss';
|
||||
|
||||
function artplayerPluginPlaylist(art) {
|
||||
const {
|
||||
utils: { append, errorHandle, sleep },
|
||||
utils: { append, errorHandle, sleep, inverseClass },
|
||||
} = art.constructor;
|
||||
const {
|
||||
player,
|
||||
@@ -70,11 +70,9 @@ function artplayerPluginPlaylist(art) {
|
||||
|
||||
art.on('afterAttachUrl', () => {
|
||||
const index = playlist.findIndex(item => item.url === $video.src);
|
||||
const $children = Array.from($playlistInner.children);
|
||||
const $item = $children[index];
|
||||
const $item = Array.from($playlistInner.children)[index];
|
||||
if (index !== -1 && $item) {
|
||||
$children.forEach(item => item.classList.remove('active'));
|
||||
$item.classList.add('active');
|
||||
inverseClass($item, 'active');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -99,9 +99,9 @@ export function append(parent, child) {
|
||||
if (child instanceof Element) {
|
||||
parent.appendChild(child);
|
||||
} else {
|
||||
parent.insertAdjacentHTML('beforeend', child);
|
||||
parent.insertAdjacentHTML('beforeend', String(child));
|
||||
}
|
||||
return parent.lastElementChild;
|
||||
return parent.lastElementChild || parent.lastChild;
|
||||
}
|
||||
|
||||
export function remove(child) {
|
||||
|
||||
Reference in new issue
Block a user