mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Fix image loading on details pages
This commit is contained in:
parent
ac9668f9bb
commit
6dde11349a
1 changed files with 25 additions and 3 deletions
|
@ -3,12 +3,33 @@ import userSettings from 'userSettings';
|
||||||
import 'css!./style';
|
import 'css!./style';
|
||||||
/* eslint-disable indent */
|
/* eslint-disable indent */
|
||||||
|
|
||||||
|
export function lazyImage(elem, source, enableEffects) {
|
||||||
|
|
||||||
|
if (!elem) {
|
||||||
|
throw new Error('elem cannot be null');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!source) {
|
||||||
|
source = elem.getAttribute('data-src');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!source) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fillImageElement(elem, source, enableEffects);
|
||||||
|
}
|
||||||
|
|
||||||
export function fillImage(entry) {
|
export function fillImage(entry) {
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
throw new Error('entry cannot be null');
|
throw new Error('entry cannot be null');
|
||||||
}
|
}
|
||||||
|
|
||||||
var source = entry.target.getAttribute('data-src');
|
if (entry.target) {
|
||||||
|
var source = entry.target.getAttribute('data-src');
|
||||||
|
} else {
|
||||||
|
var source = entry;
|
||||||
|
}
|
||||||
|
|
||||||
if (entry.intersectionRatio > 0 && source) {
|
if (entry.intersectionRatio > 0 && source) {
|
||||||
fillImageElement(entry.target, source);
|
fillImageElement(entry.target, source);
|
||||||
|
@ -21,7 +42,7 @@ import 'css!./style';
|
||||||
let preloaderImg = new Image();
|
let preloaderImg = new Image();
|
||||||
preloaderImg.src = url;
|
preloaderImg.src = url;
|
||||||
|
|
||||||
preloaderImg.addEventListener('load', (event) => {
|
preloaderImg.addEventListener('load', () => {
|
||||||
if (elem.tagName !== "IMG") {
|
if (elem.tagName !== "IMG") {
|
||||||
elem.style.backgroundImage = "url('" + url + "')";
|
elem.style.backgroundImage = "url('" + url + "')";
|
||||||
} else {
|
} else {
|
||||||
|
@ -134,7 +155,8 @@ import 'css!./style';
|
||||||
/* eslint-enable indent */
|
/* eslint-enable indent */
|
||||||
export default {
|
export default {
|
||||||
fillImages: fillImages,
|
fillImages: fillImages,
|
||||||
lazyImage: fillImage,
|
fillImage: fillImage,
|
||||||
|
lazyImage: lazyImage,
|
||||||
lazyChildren: lazyChildren,
|
lazyChildren: lazyChildren,
|
||||||
getPrimaryImageAspectRatio: getPrimaryImageAspectRatio
|
getPrimaryImageAspectRatio: getPrimaryImageAspectRatio
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue