update home,about,solutions

This commit is contained in:
2026-06-01 20:20:14 +05:30
parent 8d74f7063e
commit a59a5e79dc
19 changed files with 3543 additions and 1381 deletions

View File

@@ -19,6 +19,11 @@ export default function AnimationProvider({ children }: { children: React.ReactN
duration: 0.8,
});
// Mobile browsers fire `resize` when the address bar shows/hides while
// scrolling. Refreshing ScrollTrigger on every one of those caused jumpy /
// re-hidden animations on phones. Ignore those spurious resizes.
ScrollTrigger.config({ ignoreMobileResize: true });
const initDecorativeBlocks = () => {
// Clean up previous block triggers to avoid duplicates
ScrollTrigger.getAll().forEach((t) => {
@@ -27,6 +32,7 @@ export default function AnimationProvider({ children }: { children: React.ReactN
}
});
const vh = window.innerHeight || document.documentElement.clientHeight;
const decorativeBlocks = document.querySelectorAll(".block-decoration");
decorativeBlocks.forEach((block) => {
ScrollTrigger.create({
@@ -50,6 +56,14 @@ export default function AnimationProvider({ children }: { children: React.ReactN
block.classList.remove("animated");
},
});
// ScrollTrigger does not fire onEnter for blocks already in view at
// creation — on larger / taller screens those stayed un-animated.
// Reveal any block already intersecting the viewport.
const r = block.getBoundingClientRect();
if (r.top < vh && r.bottom > 0) {
block.classList.add("animated");
}
});
};
@@ -83,15 +97,22 @@ export default function AnimationProvider({ children }: { children: React.ReactN
};
window.addEventListener("load", handleLoad);
// Also refresh on window resize
// Refresh on window resize — debounced so dragging the window across
// breakpoints recomputes trigger positions once it settles, instead of
// thrashing on every intermediate pixel.
let resizeTimer: ReturnType<typeof setTimeout>;
const handleResize = () => {
initDecorativeBlocks();
ScrollTrigger.refresh(true);
clearTimeout(resizeTimer);
resizeTimer = setTimeout(() => {
initDecorativeBlocks();
ScrollTrigger.refresh(true);
}, 200);
};
window.addEventListener("resize", handleResize);
return () => {
timeouts.forEach(clearTimeout);
clearTimeout(resizeTimer);
window.removeEventListener("load", handleLoad);
window.removeEventListener("resize", handleResize);
ScrollTrigger.getAll().forEach((t) => t.kill());