Skip to content

Commit c129d71

Browse files
committed
perf(sections): gate heavy effects to desktop viewport
Skip clover parallax (company-intro) and conic-gradient border animation (oma-section) on mobile/tablet where they don't materially help and add GPU cost. Falls back to a static conic gradient on oma section.
1 parent d105d64 commit c129d71

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

components/site/company-intro.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useRef } from "react";
44
import Image from "next/image";
55
import { motion, useReducedMotion, useScroll, useTransform } from "motion/react";
66
import { SectionHeadingUnderline } from "@/components/site/section-heading-underline";
7+
import { useMediaQuery } from "@/lib/use-media-query";
78

89
const PARAGRAPHS = [
910
{
@@ -26,12 +27,14 @@ const PARAGRAPHS = [
2627

2728
export function CompanyIntro() {
2829
const reduceMotion = useReducedMotion();
30+
const isDesktop = useMediaQuery("(min-width: 1024px)");
2931
const sectionRef = useRef<HTMLElement>(null);
3032
const { scrollYProgress } = useScroll({
3133
target: sectionRef,
3234
offset: ["start end", "end start"],
3335
});
3436
const cloverY = useTransform(scrollYProgress, [0, 1], [40, -80]);
37+
const heavyEffects = isDesktop && !reduceMotion;
3538

3639
const container = {
3740
hidden: {},
@@ -60,15 +63,15 @@ export function CompanyIntro() {
6063
<motion.div
6164
aria-hidden
6265
className="pointer-events-none absolute -right-20 -bottom-24 select-none md:-right-24 md:-bottom-32"
63-
style={reduceMotion ? undefined : { y: cloverY }}
66+
style={heavyEffects ? { y: cloverY } : undefined}
6467
>
6568
<Image
6669
src="/logo.png"
6770
alt=""
6871
width={720}
6972
height={720}
7073
unoptimized
71-
className="h-[360px] w-[360px] opacity-[0.09] motion-safe:animate-[spin_120s_linear_infinite] md:h-[640px] md:w-[640px]"
74+
className="h-[360px] w-[360px] opacity-[0.09] lg:motion-safe:animate-[spin_120s_linear_infinite] md:h-[640px] md:w-[640px]"
7275
/>
7376
</motion.div>
7477
<div className="relative mx-auto w-full max-w-6xl px-6 md:px-12">

components/site/oma-section.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { LinkButton } from "@/components/ui/button";
1313
import { SectionHeadingUnderline } from "@/components/site/section-heading-underline";
1414
import { TypewriterText } from "@/components/site/typewriter-text";
1515
import { OMA_DOCS_URL, OMA_REPO_URL } from "@/lib/oma-content";
16+
import { useMediaQuery } from "@/lib/use-media-query";
1617

1718
const AGENTS = [
1819
{ tag: "기획자", desc: "어떤 화면이 필요한지 정리" },
@@ -30,21 +31,26 @@ const HIGHLIGHTS = [
3031

3132
const easeOutExpo = [0.22, 1, 0.36, 1] as const;
3233

34+
const STATIC_BORDER_BG =
35+
"conic-gradient(from 0deg at 50% 50%, transparent 0deg, rgba(122,185,76,0.55) 80deg, transparent 160deg, transparent 240deg, rgba(15,84,64,0.35) 320deg, transparent 360deg)";
36+
3337
export function OmaSection() {
3438
const reduceMotion = useReducedMotion();
39+
const isDesktop = useMediaQuery("(min-width: 1024px)");
40+
const animateBorder = isDesktop && !reduceMotion;
3541
const angle = useMotionValue(0);
3642

3743
useEffect(() => {
38-
if (reduceMotion) return;
44+
if (!animateBorder) return;
3945
const ctrl = animate(angle, 360, {
4046
duration: 7,
4147
repeat: Infinity,
4248
ease: "linear",
4349
});
4450
return () => ctrl.stop();
45-
}, [angle, reduceMotion]);
51+
}, [angle, animateBorder]);
4652

47-
const borderBackground = useMotionTemplate`conic-gradient(from ${angle}deg at 50% 50%, transparent 0deg, rgba(122,185,76,0.55) 80deg, transparent 160deg, transparent 240deg, rgba(15,84,64,0.35) 320deg, transparent 360deg)`;
53+
const animatedBorderBackground = useMotionTemplate`conic-gradient(from ${angle}deg at 50% 50%, transparent 0deg, rgba(122,185,76,0.55) 80deg, transparent 160deg, transparent 240deg, rgba(15,84,64,0.35) 320deg, transparent 360deg)`;
4854

4955
const fadeUpInitial = reduceMotion ? { opacity: 0 } : { opacity: 0, y: 20 };
5056
const fadeUpAnimate = reduceMotion
@@ -154,11 +160,11 @@ export function OmaSection() {
154160
viewport={{ once: true, amount: 0.25 }}
155161
className="relative"
156162
>
157-
{/* Animated conic gradient border */}
163+
{/* Animated conic gradient border (desktop) / static fallback (mobile) */}
158164
<motion.div
159165
aria-hidden
160166
className="pointer-events-none absolute -inset-[1.5px] rounded-2xl opacity-90 blur-[0.5px]"
161-
style={{ background: borderBackground }}
167+
style={{ background: animateBorder ? animatedBorderBackground : STATIC_BORDER_BG }}
162168
/>
163169
{/* Soft outer glow */}
164170
<div

0 commit comments

Comments
 (0)