diff --git a/surfsense_web/components/homepage/hero-section.tsx b/surfsense_web/components/homepage/hero-section.tsx index 5723b7e55..830f9febf 100644 --- a/surfsense_web/components/homepage/hero-section.tsx +++ b/surfsense_web/components/homepage/hero-section.tsx @@ -1,14 +1,38 @@ "use client"; import { AnimatePresence, motion } from "motion/react"; +import dynamic from "next/dynamic"; import Link from "next/link"; import type React from "react"; import { useEffect, useRef, useState } from "react"; import Balancer from "react-wrap-balancer"; -import { HeroCarousel } from "@/components/ui/hero-carousel"; import { AUTH_TYPE, BACKEND_URL } from "@/lib/env-config"; import { trackLoginAttempt } from "@/lib/posthog/events"; import { cn } from "@/lib/utils"; +const HeroCarousel = dynamic( + () => import("@/components/ui/hero-carousel").then((m) => ({ default: m.HeroCarousel })), + { + ssr: false, + loading: () => ( +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ), + } +); + // Official Google "G" logo with brand colors const GoogleLogo = ({ className }: { className?: string }) => ( diff --git a/surfsense_web/components/ui/hero-carousel.tsx b/surfsense_web/components/ui/hero-carousel.tsx index adf7126b8..eb9584848 100644 --- a/surfsense_web/components/ui/hero-carousel.tsx +++ b/surfsense_web/components/ui/hero-carousel.tsx @@ -81,11 +81,23 @@ function HeroCarouselCard({ useEffect(() => { const video = videoRef.current; - if (video) { - setHasLoaded(false); - video.currentTime = 0; - video.play().catch(() => {}); - } + if (!video) return; + + setHasLoaded(false); + video.currentTime = 0; + + const observer = new IntersectionObserver( + ([entry]) => { + if (entry.isIntersecting) { + video.play().catch(() => {}); + observer.disconnect(); + } + }, + { threshold: 0.1 } + ); + observer.observe(video); + + return () => observer.disconnect(); }, [src]); const handleCanPlay = useCallback(() => { @@ -94,7 +106,7 @@ function HeroCarouselCard({ return ( <> -
+

@@ -108,7 +120,7 @@ function HeroCarouselCard({