Skip to content

Commit

Permalink
IntersectionObserver has been available since 2019
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Jun 10, 2024
1 parent 82488d1 commit 7ebe4e8
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions funnel/assets/js/utils/lazyloadimage.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,7 @@
const LazyloadImg = {
init(imgClassName) {
const intersectionObserverComponents = function intersectionObserverComponents() {
LazyloadImg.addObserver(imgClassName);
};

if (document.querySelector(`.${imgClassName}`)) {
if (
!(
'IntersectionObserver' in global &&
'IntersectionObserverEntry' in global &&
'intersectionRatio' in IntersectionObserverEntry.prototype
)
) {
const polyfill = document.createElement('script');
polyfill.setAttribute('type', 'text/javascript');
polyfill.setAttribute(
'src',
'https://cdn.polyfill.io/v2/polyfill.min.js?features=IntersectionObserver',
);
polyfill.onload = function loadintersectionObserverComponents() {
intersectionObserverComponents();
};
document.head.appendChild(polyfill);
} else {
intersectionObserverComponents();
}
LazyloadImg.addObserver(imgClassName);
}
},
displayImages(img) {
Expand Down

0 comments on commit 7ebe4e8

Please sign in to comment.