MCPcopy Create free account
hub / github.com/MALSync/MALSync / loadImage

Function loadImage

src/utils/general.ts:771–788  ·  view source on GitHub ↗
(el, fn)

Source from the content-addressed store, hash-verified

769 */
770 // eslint-disable-next-line
771 function loadImage(el, fn) {
772 if (!j.$(el).is(':visible')) return false;
773 if (j.$(el).hasClass('lazyBack')) {
774 j.$(el)
775 .css('background-image', `url(${el.getAttribute('data-src')})`)
776 .removeClass('lazyBack');
777 } else {
778 const img = new Image();
779 const src = el.getAttribute('data-src');
780 img.onload = function () {
781 if (el.parent) el.parent.replaceChild(img, el);
782 else el.src = src;
783 // eslint-disable-next-line
784 fn ? fn() : null;
785 };
786 img.src = src;
787 }
788 }
789
790 for (let i = 0; i < lazyimages.length; i++) {
791 $(lazyimages[i]).addClass('init');

Callers 1

processScrollFunction · 0.85

Calls 1

fnFunction · 0.50

Tested by

no test coverage detected