505e314a31
Fixes #1196
27 lines
515 B
JavaScript
27 lines
515 B
JavaScript
/**
|
|
* Set up image lazy-load
|
|
*/
|
|
|
|
function stopShimmer($node) {
|
|
$node.parent().removeClass('shimmer');
|
|
}
|
|
|
|
export function imgLazy() {
|
|
const $images = $('main img[data-src]');
|
|
|
|
if ($images.length <= 0) {
|
|
return;
|
|
}
|
|
|
|
/* Stop shimmer when image loaded */
|
|
document.addEventListener('lazyloaded', function (e) {
|
|
stopShimmer($(e.target));
|
|
});
|
|
|
|
/* Stop shimmer from cached images */
|
|
$images.each(function () {
|
|
if ($(this).hasClass('ls-is-cached')) {
|
|
stopShimmer($(this));
|
|
}
|
|
});
|
|
}
|