Skip to content

Commit 47b0bb0

Browse files
authored
Update lazy.phtml
1 parent c2ac3b0 commit 47b0bb0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

view/frontend/templates/lazy.phtml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,26 @@
5050
function loadScript(e,t){var a,n,r;n=!1,(a=document.createElement("script")).type="text/javascript",a.src=e,a.onload=a.onreadystatechange=function(){n||this.readyState&&"complete"!=this.readyState||(n=!0,t())},(r=document.getElementsByTagName("script")[0]).parentNode.insertBefore(a,r)}
5151
loadScript(jsSrc, function(){
5252
var lazyLoadConfig = <?= $block->getLazyLoadConfig() ?>;
53+
var myLazyLoad = false;
5354
if (document.readyState !== 'loading') {
54-
var myLazyLoad = new LazyLoad(lazyLoadConfig);
55+
myLazyLoad = new LazyLoad(lazyLoadConfig);
5556
setTimeout(function(){
5657
new LazyLoad(lazyLoadConfig);
5758
}, 2000);
5859
} else {
5960
document.addEventListener("DOMContentLoaded", function() {
60-
var myLazyLoad = new LazyLoad(lazyLoadConfig);
61+
myLazyLoad = new LazyLoad(lazyLoadConfig);
6162
setTimeout(function(){
6263
new LazyLoad(lazyLoadConfig);
6364
}, 2000);
6465
});
6566
}
67+
68+
document.body.addEventListener("contentUpdated", function(){
69+
if (myLazyLoad) {
70+
myLazyLoad.update();
71+
}
72+
});
6673
return true;
6774
});
6875
}

0 commit comments

Comments
 (0)