fix: the cached image is covered by shimmer (#1100)

This commit is contained in:
Cotes Chung 2023-06-26 23:59:59 +08:00
parent c075e11a4e
commit df8ff546ec
No known key found for this signature in database
GPG key ID: 0D9E54843167A808

View file

@ -2,14 +2,26 @@
* Set up image lazy-load
*/
function stopShimmer($node) {
$node.parent().removeClass('shimmer');
}
export function imgLazy() {
if ($('#core-wrapper img[data-src]') <= 0) {
const $images = $('#core-wrapper img[data-src]');
if ($images.length <= 0) {
return;
}
/* Stop shimmer when image loaded */
document.addEventListener('lazyloaded', function (e) {
const $img = $(e.target);
$img.parent().removeClass('shimmer');
stopShimmer($(e.target));
});
/* Stop shimmer from cached images */
$images.each(function () {
if ($(this).hasClass('ls-is-cached')) {
stopShimmer($(this));
}
});
}