| 1 |
(function () { |
| 2 |
'use strict'; |
| 3 |
|
| 4 |
document.querySelectorAll('.bkbg-tc-wrapper').forEach(function (wrapper) { |
| 5 |
if (!('IntersectionObserver' in window)) return; |
| 6 |
|
| 7 |
var leftCol = wrapper.querySelector('.bkbg-tc-col--left'); |
| 8 |
var rightCol = wrapper.querySelector('.bkbg-tc-col--right'); |
| 9 |
|
| 10 |
if (leftCol) { |
| 11 |
leftCol.style.opacity = '0'; |
| 12 |
leftCol.style.transform = 'translateX(-28px)'; |
| 13 |
leftCol.style.transition = 'opacity 0.55s ease, transform 0.55s ease'; |
| 14 |
} |
| 15 |
if (rightCol) { |
| 16 |
rightCol.style.opacity = '0'; |
| 17 |
rightCol.style.transform = 'translateX(28px)'; |
| 18 |
rightCol.style.transition = 'opacity 0.55s ease 0.1s, transform 0.55s ease 0.1s'; |
| 19 |
} |
| 20 |
|
| 21 |
var observed = false; |
| 22 |
var io = new IntersectionObserver(function (entries) { |
| 23 |
entries.forEach(function (entry) { |
| 24 |
if (!entry.isIntersecting || observed) return; |
| 25 |
observed = true; |
| 26 |
if (leftCol) { leftCol.style.opacity = '1'; leftCol.style.transform = 'translateX(0)'; } |
| 27 |
if (rightCol) { rightCol.style.opacity = '1'; rightCol.style.transform = 'translateX(0)'; } |
| 28 |
io.disconnect(); |
| 29 |
}); |
| 30 |
}, { threshold: 0.1 }); |
| 31 |
|
| 32 |
if (leftCol) io.observe(leftCol); |
| 33 |
if (rightCol) io.observe(rightCol); |
| 34 |
}); |
| 35 |
})(); |
| 36 |
|