39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
/**
|
|
* Семейные классы — reveal-анимации секций.
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var sections = document.querySelectorAll('.page-family-classes .reveal');
|
|
if (!sections.length || !('IntersectionObserver' in window)) {
|
|
sections.forEach(function (el) {
|
|
el.classList.add('reveal--visible');
|
|
});
|
|
return;
|
|
}
|
|
|
|
var observer = new IntersectionObserver(function (entries) {
|
|
entries.forEach(function (entry) {
|
|
if (entry.isIntersecting) {
|
|
entry.target.classList.add('reveal--visible');
|
|
observer.unobserve(entry.target);
|
|
}
|
|
});
|
|
}, { threshold: 0.12 });
|
|
|
|
sections.forEach(function (el) {
|
|
observer.observe(el);
|
|
});
|
|
|
|
// Sticky CTA: показываем при уходе hero из вьюпорта
|
|
var sticky = document.querySelector('.sticky-cta-desktop');
|
|
var hero = document.querySelector('.page-family-classes .family-hero');
|
|
if (sticky && hero && 'IntersectionObserver' in window) {
|
|
new IntersectionObserver(function (entries) {
|
|
entries.forEach(function (entry) {
|
|
sticky.classList.toggle('visible', !entry.isIntersecting);
|
|
});
|
|
}, { threshold: 0 }).observe(hero);
|
|
}
|
|
})();
|