Skip to content

Commit df8ff54

Browse files
committed
fix: the cached image is covered by shimmer (#1100)
1 parent c075e11 commit df8ff54

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

_javascript/modules/components/img-lazyload.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,26 @@
22
* Set up image lazy-load
33
*/
44

5+
function stopShimmer($node) {
6+
$node.parent().removeClass('shimmer');
7+
}
8+
59
export function imgLazy() {
6-
if ($('#core-wrapper img[data-src]') <= 0) {
10+
const $images = $('#core-wrapper img[data-src]');
11+
12+
if ($images.length <= 0) {
713
return;
814
}
915

1016
/* Stop shimmer when image loaded */
1117
document.addEventListener('lazyloaded', function (e) {
12-
const $img = $(e.target);
13-
$img.parent().removeClass('shimmer');
18+
stopShimmer($(e.target));
19+
});
20+
21+
/* Stop shimmer from cached images */
22+
$images.each(function () {
23+
if ($(this).hasClass('ls-is-cached')) {
24+
stopShimmer($(this));
25+
}
1426
});
1527
}

0 commit comments

Comments
 (0)