mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-28 18:41:20 -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) {
|
function artplayerPluginPlaylist(art) {
|
||||||
const {
|
const {
|
||||||
utils: { append, errorHandle, sleep },
|
utils: { append, errorHandle, sleep, inverseClass },
|
||||||
} = art.constructor;
|
} = art.constructor;
|
||||||
const {
|
const {
|
||||||
player,
|
player,
|
||||||
@@ -70,11 +70,9 @@ function artplayerPluginPlaylist(art) {
|
|||||||
|
|
||||||
art.on('afterAttachUrl', () => {
|
art.on('afterAttachUrl', () => {
|
||||||
const index = playlist.findIndex(item => item.url === $video.src);
|
const index = playlist.findIndex(item => item.url === $video.src);
|
||||||
const $children = Array.from($playlistInner.children);
|
const $item = Array.from($playlistInner.children)[index];
|
||||||
const $item = $children[index];
|
|
||||||
if (index !== -1 && $item) {
|
if (index !== -1 && $item) {
|
||||||
$children.forEach(item => item.classList.remove('active'));
|
inverseClass($item, 'active');
|
||||||
$item.classList.add('active');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -99,9 +99,9 @@ export function append(parent, child) {
|
|||||||
if (child instanceof Element) {
|
if (child instanceof Element) {
|
||||||
parent.appendChild(child);
|
parent.appendChild(child);
|
||||||
} else {
|
} else {
|
||||||
parent.insertAdjacentHTML('beforeend', child);
|
parent.insertAdjacentHTML('beforeend', String(child));
|
||||||
}
|
}
|
||||||
return parent.lastElementChild;
|
return parent.lastElementChild || parent.lastChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function remove(child) {
|
export function remove(child) {
|
||||||
|
|||||||
Reference in new issue
Block a user