2023-03-18 01:28:44 +03:00
|
|
|
/**
|
2023-06-26 16:54:20 +03:00
|
|
|
* Set up image lazy-load
|
2023-03-18 01:28:44 +03:00
|
|
|
*/
|
|
|
|
|
2023-06-26 18:59:59 +03:00
|
|
|
function stopShimmer($node) {
|
|
|
|
$node.parent().removeClass('shimmer');
|
|
|
|
}
|
|
|
|
|
2023-03-18 01:28:44 +03:00
|
|
|
export function imgLazy() {
|
2023-09-08 17:48:37 +03:00
|
|
|
const $images = $('main img[data-src]');
|
2023-06-26 18:59:59 +03:00
|
|
|
|
|
|
|
if ($images.length <= 0) {
|
2023-03-18 01:28:44 +03:00
|
|
|
return;
|
|
|
|
}
|
2023-06-26 16:54:20 +03:00
|
|
|
|
|
|
|
/* Stop shimmer when image loaded */
|
|
|
|
document.addEventListener('lazyloaded', function (e) {
|
2023-06-26 18:59:59 +03:00
|
|
|
stopShimmer($(e.target));
|
|
|
|
});
|
|
|
|
|
|
|
|
/* Stop shimmer from cached images */
|
|
|
|
$images.each(function () {
|
|
|
|
if ($(this).hasClass('ls-is-cached')) {
|
|
|
|
stopShimmer($(this));
|
|
|
|
}
|
2023-06-26 16:54:20 +03:00
|
|
|
});
|
2023-03-18 01:28:44 +03:00
|
|
|
}
|