Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Add fallback trigger animation if no need to anim on scroll

Joshen Lim700e7eb32991
diff --git a/www/components/CountUp.tsx b/www/components/CountUp.tsx
index 3e5f12f98e3..c9e9de114ac 100644
--- a/www/components/CountUp.tsx
+++ b/www/components/CountUp.tsx
@@ -38,7 +38,17 @@ const CountUp = (props: Props) => {
}
}
- if (triggerAnimOnScroll) window.addEventListener('scroll', handleScroll, { passive: true })
+ if (triggerAnimOnScroll) {
+ window.addEventListener('scroll', handleScroll, { passive: true })
+ } else {
+ const counter = setInterval(() => {
+ frame++
+ const progress = easeOutQuad(frame / totalFrames)
+ setCount(countTo * progress)
+
+ if (frame === totalFrames) clearInterval(counter)
+ }, frameDuration)
+ }
return () => {
if (triggerAnimOnScroll) window.removeEventListener('scroll', handleScroll)