mirror of
https://github.com/SuperBFG7/ympd
synced 2025-10-30 05:13:00 +00:00
Fix: optimize lazy loading of coverimages
This commit is contained in:
@@ -61,6 +61,7 @@ small {
|
|||||||
|
|
||||||
.album-cover {
|
.album-cover {
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
|
background-image: url("/assets/coverimage-loading.png");
|
||||||
border: 1px solid black;
|
border: 1px solid black;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|||||||
@@ -1319,7 +1319,6 @@ function parseListDBtags(obj) {
|
|||||||
card.classList.add('mr-0');
|
card.classList.add('mr-0');
|
||||||
card.setAttribute('id', id);
|
card.setAttribute('id', id);
|
||||||
card.setAttribute('data-album', encodeURI(obj.data[i].value));
|
card.setAttribute('data-album', encodeURI(obj.data[i].value));
|
||||||
card.setAttribute('data-init', 'false');
|
|
||||||
card.innerHTML = '<div class="card mb-4" id="card' + id + '">' +
|
card.innerHTML = '<div class="card mb-4" id="card' + id + '">' +
|
||||||
' <a href="#" class="card-img-top"></a>' +
|
' <a href="#" class="card-img-top"></a>' +
|
||||||
' <div class="card-body">' +
|
' <div class="card-body">' +
|
||||||
@@ -1399,11 +1398,9 @@ function createListTitleObserver(ele) {
|
|||||||
function getListTitles(changes, observer) {
|
function getListTitles(changes, observer) {
|
||||||
changes.forEach(change => {
|
changes.forEach(change => {
|
||||||
if (change.intersectionRatio > 0) {
|
if (change.intersectionRatio > 0) {
|
||||||
if (change.target.getAttribute('data-init') == 'false') {
|
observer.unobserve(change.target);
|
||||||
change.target.setAttribute('data-init', 'true');
|
var album = decodeURI(change.target.getAttribute('data-album'));
|
||||||
var album = decodeURI(change.target.getAttribute('data-album'));
|
sendAPI({"cmd": "MPD_API_DATABASE_TAG_ALBUM_TITLE_LIST", "data": { "album": album, "search": app.current.search, "tag": app.current.view}}, parseListTitles);
|
||||||
sendAPI({"cmd": "MPD_API_DATABASE_TAG_ALBUM_TITLE_LIST", "data": { "album": album, "search": app.current.search, "tag": app.current.view}}, parseListTitles);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user