| 1 |
(function () { |
| 2 |
'use strict'; |
| 3 |
|
| 4 |
/* Gradient section – IntersectionObserver content entrance */ |
| 5 |
document.querySelectorAll('.bkbg-gs-wrapper').forEach(function (wrapper) { |
| 6 |
var inner = wrapper.querySelector('.bkbg-gs-inner'); |
| 7 |
if (!inner || !('IntersectionObserver' in window)) return; |
| 8 |
|
| 9 |
/* Animate content in when section enters viewport */ |
| 10 |
var children = inner.children; |
| 11 |
Array.prototype.forEach.call(children, function (child) { |
| 12 |
child.style.opacity = '0'; |
| 13 |
child.style.transform = 'translateY(22px)'; |
| 14 |
child.style.transition = 'opacity 0.6s ease, transform 0.6s ease'; |
| 15 |
}); |
| 16 |
|
| 17 |
var io = new IntersectionObserver(function (entries) { |
| 18 |
entries.forEach(function (entry) { |
| 19 |
if (!entry.isIntersecting) return; |
| 20 |
Array.prototype.forEach.call(children, function (child, i) { |
| 21 |
setTimeout(function () { |
| 22 |
child.style.opacity = '1'; |
| 23 |
child.style.transform = 'translateY(0)'; |
| 24 |
}, i * 100); |
| 25 |
}); |
| 26 |
io.unobserve(wrapper); |
| 27 |
}); |
| 28 |
}, { threshold: 0.15 }); |
| 29 |
|
| 30 |
io.observe(wrapper); |
| 31 |
}); |
| 32 |
})(); |
| 33 |
|