| 1 |
(function () { |
| 2 |
'use strict'; |
| 3 |
|
| 4 |
function initFeatureGrid(wrapper) { |
| 5 |
var cards = wrapper.querySelectorAll('.bkbg-fg-card.bkbg-fg-anim'); |
| 6 |
if (!cards.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-fg-visible'); |
| 12 |
io.unobserve(entry.target); |
| 13 |
} |
| 14 |
}); |
| 15 |
}, { threshold: 0.12 }); |
| 16 |
|
| 17 |
cards.forEach(function (card) { |
| 18 |
io.observe(card); |
| 19 |
}); |
| 20 |
} |
| 21 |
|
| 22 |
function init() { |
| 23 |
document.querySelectorAll('.bkbg-fg-wrapper').forEach(initFeatureGrid); |
| 24 |
} |
| 25 |
|
| 26 |
if (document.readyState === 'loading') { |
| 27 |
document.addEventListener('DOMContentLoaded', init); |
| 28 |
} else { |
| 29 |
init(); |
| 30 |
} |
| 31 |
})(); |
| 32 |
|