| 1 |
(function () { |
| 2 |
'use strict'; |
| 3 |
|
| 4 |
function initCollage() { |
| 5 |
var collages = document.querySelectorAll('.bkbg-image-collage[data-animate-in="1"]'); |
| 6 |
if (!collages.length) return; |
| 7 |
|
| 8 |
var io = new IntersectionObserver(function (entries) { |
| 9 |
entries.forEach(function (entry) { |
| 10 |
if (entry.isIntersecting) { |
| 11 |
entry.target.classList.add('bkbg-ic--visible'); |
| 12 |
io.unobserve(entry.target); |
| 13 |
} |
| 14 |
}); |
| 15 |
}, { threshold: 0.15 }); |
| 16 |
|
| 17 |
collages.forEach(function (collage) { io.observe(collage); }); |
| 18 |
} |
| 19 |
|
| 20 |
if (document.readyState === 'loading') { |
| 21 |
document.addEventListener('DOMContentLoaded', initCollage); |
| 22 |
} else { |
| 23 |
initCollage(); |
| 24 |
} |
| 25 |
}()); |
| 26 |
|