Hero: replace particle field with cobe globe (Capricorn view, multi-axis drag, reduced-motion safe), telemetry HUD with pointer parallax, particle text build effect, Space Grotesk display font. SEO: short titles with template, PT-BR accents, twitter cards on dynamic cases, escaped JSON-LD via lib/jsonld.ts, CSP report-only, 25 service FAQs answer-first. Design: fix TW4 layered reset killing spacing utilities, literal @theme tokens, mobile hero overflow, header overlap, empty case cards. Remove framer-motion (unified on motion/react), header version badge, phone number from hero CTA. Production build verified (24 static pages).
57 lines
1.2 KiB
TypeScript
57 lines
1.2 KiB
TypeScript
"use client";
|
|
|
|
import { gsap } from "gsap";
|
|
import { ScrollTrigger } from "gsap/ScrollTrigger";
|
|
import { useEffect, useRef } from "react";
|
|
|
|
export function useScrollReveal(options?: {
|
|
y?: number;
|
|
duration?: number;
|
|
delay?: number;
|
|
ease?: string;
|
|
start?: string;
|
|
end?: string;
|
|
scrub?: boolean | number;
|
|
}) {
|
|
const ref = useRef<HTMLElement>(null);
|
|
|
|
useEffect(() => {
|
|
if (!ref.current) return;
|
|
|
|
// Lazy registration to avoid Next.js hydration mismatch issues
|
|
gsap.registerPlugin(ScrollTrigger);
|
|
|
|
const ctx = gsap.context(() => {
|
|
gsap.fromTo(
|
|
ref.current,
|
|
{ y: options?.y ?? 60, opacity: 0 },
|
|
{
|
|
y: 0,
|
|
opacity: 1,
|
|
duration: options?.duration ?? 0.9,
|
|
delay: options?.delay ?? 0,
|
|
ease: options?.ease ?? "power3.out",
|
|
scrollTrigger: {
|
|
trigger: ref.current,
|
|
start: options?.start ?? "top 85%",
|
|
end: options?.end ?? "top 50%",
|
|
scrub: options?.scrub ?? false,
|
|
},
|
|
},
|
|
);
|
|
}, ref);
|
|
|
|
return () => ctx.revert();
|
|
}, [
|
|
options?.y,
|
|
options?.duration,
|
|
options?.delay,
|
|
options?.ease,
|
|
options?.start,
|
|
options?.end,
|
|
options?.scrub,
|
|
]);
|
|
|
|
return ref;
|
|
}
|