fix: restore gsap.set pre-hide + simpler observer (threshold 0.1, no rootMargin) — ensures no flash and animations fire correctly on scroll

This commit is contained in:
2026-08-20 22:20:56 +00:00
parent 840982dc2e
commit 4afa74bd16
+6 -7
View File
@@ -549,11 +549,11 @@ var si = 0,
entries.forEach(function (entry) { entries.forEach(function (entry) {
if (!entry.isIntersecting) return; if (!entry.isIntersecting) return;
var grid = entry.target; var grid = entry.target;
if (animated[grid.dataset.section]) return; var key = grid.className || 'anon';
animated[grid.dataset.section] = true; if (animated[key]) return;
var items = grid.children; animated[key] = true;
gsap.fromTo( gsap.fromTo(
items, grid.children,
{ y: 30, opacity: 0 }, { y: 30, opacity: 0 },
{ {
y: 0, y: 0,
@@ -565,14 +565,13 @@ var si = 0,
} }
); );
}); });
}, { threshold: 0.12, rootMargin: '0px 0px -40px 0px' }); }, { threshold: 0.1 });
var grids = document.querySelectorAll( var grids = document.querySelectorAll(
'.features-grid, .faq-grid, .pricing-grid, .blog-grid, .biz-wizard .container' '.features-grid, .faq-grid, .pricing-grid, .blog-grid, .biz-wizard .container'
); );
grids.forEach(function (g) { grids.forEach(function (g) {
g.dataset.section = g.className || 'anon'; /* Pre-set children invisible so no flash even before observer fires */
/* Pre-set children to hidden state so they start invisible */
gsap.set(g.children, { y: 30, opacity: 0 }); gsap.set(g.children, { y: 30, opacity: 0 });
observer.observe(g); observer.observe(g);
}); });