diff --git a/src/app/components/Hero.tsx b/src/app/components/Hero.tsx index b6902de..5b38724 100644 --- a/src/app/components/Hero.tsx +++ b/src/app/components/Hero.tsx @@ -1,6 +1,7 @@ import { motion, useReducedMotion } from 'motion/react'; import { Smartphone, Zap, TrendingUp, Sparkles } from 'lucide-react'; import { useState, useRef } from 'react'; +import { useInView } from 'motion/react'; import { TypingText } from './TypingText'; const heroImage = "https://images.unsplash.com/photo-1551288049-bebda4e38f71?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3w3Nzg4Nzd8MHwxfHNlYXJjaHwxfHxtb2Rlcm4lMjB3ZWJzaXRlJTIwZGFzaGJvYXJkJTIwZGVzaWdufGVufDF8fHx8MTc4MTcwMjY1OXww&ixlib=rb-4.1.0&q=80&w=1080&utm_source=figma&utm_medium=referral"; @@ -16,6 +17,7 @@ export function Hero() { const reduce = useReducedMotion(); const [mousePosition, setMousePosition] = useState({ x: 0, y: 0 }); const containerRef = useRef(null); + const isInView = useInView(containerRef, { margin: "200px" }); const handleMouseMove = (e: React.MouseEvent) => { if (reduce) return; @@ -38,8 +40,8 @@ export function Hero() {
{/* Gradient Mesh Background */}
-
-
+
+
@@ -57,7 +59,7 @@ export function Hero() { transition={{ duration: reduce ? 0 : 0.5 }} className="inline-flex items-center gap-2 px-4 py-2 bg-white/60 dark:bg-slate-800/60 backdrop-blur-sm rounded-full border border-indigo-100 dark:border-indigo-900 mb-6" > - + Available for new projects @@ -132,7 +134,7 @@ export function Hero() { /> - {/* Glowing gradient border overlay */} - - {/* Pulsing glow effect on icon */} (null); const reduce = useReducedMotion(); + const isInView = useInView(ref, { margin: "200px" }); const { scrollYProgress } = useScroll({ target: ref, offset: ['start end', 'end start'] }); const bgY = useTransform(scrollYProgress, [0, 1], ['-8%', '8%']); const bgScale = useTransform(scrollYProgress, [0, 0.5, 1], [1.1, 1, 1.1]); @@ -156,17 +157,17 @@ export function Services() { > @@ -194,7 +195,7 @@ export function Services() { 'linear-gradient(110deg,#4F46E5,#7C3AED,#06B6D4,#7C3AED,#4F46E5)', backgroundSize: '200% auto', }} - animate={reduce ? undefined : { backgroundPositionX: ['0%', '200%'] }} + animate={reduce || !isInView ? undefined : { backgroundPositionX: ['0%', '200%'] }} transition={{ duration: 6, repeat: Infinity, ease: 'linear' }} > diff --git a/src/app/components/Testimonials.tsx b/src/app/components/Testimonials.tsx index 83a8819..d967710 100644 --- a/src/app/components/Testimonials.tsx +++ b/src/app/components/Testimonials.tsx @@ -1,4 +1,5 @@ -import { motion, useReducedMotion } from "motion/react"; +import { motion, useReducedMotion, useInView } from "motion/react"; +import { useRef } from "react"; import { Quote, Star } from "lucide-react"; import { TypingText } from "./TypingText"; import priya from "../../assets/testimonials/priya.jpg"; @@ -169,8 +170,12 @@ function MarqueeRow({ duration?: string; label: string; }) { + const ref = useRef(null); + const isInView = useInView(ref, { margin: "200px" }); + return (