| 1 |
(function () { |
| 2 |
'use strict'; |
| 3 |
|
| 4 |
function initBentoGrid() { |
| 5 |
var grids = document.querySelectorAll('.bkbg-bento-grid[data-animate="1"]'); |
| 6 |
if (!grids.length) return; |
| 7 |
|
| 8 |
if (!('IntersectionObserver' in window)) { |
| 9 |
grids.forEach(function (grid) { |
| 10 |
grid.querySelectorAll('.bkbg-bento-cell').forEach(function (cell) { |
| 11 |
cell.classList.add('is-visible'); |
| 12 |
}); |
| 13 |
}); |
| 14 |
return; |
| 15 |
} |
| 16 |
|
| 17 |
var obs = new IntersectionObserver(function (entries) { |
| 18 |
entries.forEach(function (entry) { |
| 19 |
if (entry.isIntersecting) { |
| 20 |
entry.target.classList.add('is-visible'); |
| 21 |
obs.unobserve(entry.target); |
| 22 |
} |
| 23 |
}); |
| 24 |
}, { threshold: 0.12, rootMargin: '0px 0px -40px 0px' }); |
| 25 |
|
| 26 |
grids.forEach(function (grid) { |
| 27 |
grid.querySelectorAll('.bkbg-bento-cell').forEach(function (cell) { |
| 28 |
obs.observe(cell); |
| 29 |
}); |
| 30 |
}); |
| 31 |
} |
| 32 |
|
| 33 |
if (document.readyState === 'loading') { |
| 34 |
document.addEventListener('DOMContentLoaded', initBentoGrid); |
| 35 |
} else { |
| 36 |
initBentoGrid(); |
| 37 |
} |
| 38 |
}()); |
| 39 |
|