๋ชจ๋ํ React ์ ํ๋ฆฌ์ผ์ด์ ์ ์ํ ๊ฐ๋จํ๊ณ ๊ฐ๋ ฅํ DotLottie ์ ๋๋ฉ์ด์ ํ
โจ DotLottie + GSAP ScrollTrigger๋ก ๋ฉ์ง ์คํฌ๋กค ์ ๋๋ฉ์ด์ ์ ์ฝ๊ฒ ๋ง๋ค์ด๋ณด์ธ์!
v1.2.7์ ์ต์ ์์ ๋ฒ์ ์ ๋๋ค - 4๊ฐ์ง ์ฃผ์ React ํ๋ ์์ํฌ ์์ ์ง์
pnpm-monorepo/
โโโ packages/
โ โโโ react-lottie-hooks/ # ๐ฏ ๋ฉ์ธ ํ
๋ผ์ด๋ธ๋ฌ๋ฆฌ
โโโ examples/
โโโ nextjs-example/ # Next.js ์์
โโโ vite-example/ # Vite ์์
โโโ remix-example/ # Remix ์์
โโโ react-router-example/ # React Router ์์
# pnpm (๊ถ์ฅ)
pnpm add @jurneyx2/react-lottie-hooks @lottiefiles/dotlottie-react gsap
# npm
npm install @jurneyx2/react-lottie-hooks @lottiefiles/dotlottie-react gsap
# yarn
yarn add @jurneyx2/react-lottie-hooks @lottiefiles/dotlottie-react gsapimport React from "react";
import { DotLottieReact } from "@lottiefiles/dotlottie-react";
import { useLottieScrollTrigger } from "@jurneyx2/react-lottie-hooks";
export default function MyComponent() {
const { triggerRef, lottieContainerRef, handleDotLottieRef, isLoaded } =
useLottieScrollTrigger({
start: "top center",
end: "bottom center",
debug: process.env.NODE_ENV === "development",
});
return (
<div>
{/* ์คํฌ๋กค ํธ๋ฆฌ๊ฑฐ ์์ญ */}
<div ref={triggerRef} style={{ height: "100vh" }}>
<h2>์คํฌ๋กคํ๋ฉด ์ ๋๋ฉ์ด์
์ด ์์๋ฉ๋๋ค!</h2>
</div>
{/* DotLottie ์ ๋๋ฉ์ด์
*/}
<div ref={lottieContainerRef}>
<DotLottieReact
src="/my-animation.lottie"
loop={false}
autoplay={false}
dotLottieRefCallback={handleDotLottieRef}
/>
</div>
{isLoaded && <p>์ ๋๋ฉ์ด์
๋ก๋ ์๋ฃ! โจ</p>}
</div>
);
}๋ฉ์ธ ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋๋ค.
์ฃผ์ ํน์ง:
- ๐จ DotLottie ์ ์ฉ:
@lottiefiles/dotlottie-react์๋ฒฝ ์ง์ - ๐ฑ SSR/CSR ์์ : Next.js, Remix, React-Router v7 ๋ฑ ์๋ฒฝ ์ง์
- ๐ฏ GSAP ScrollTrigger: ์คํฌ๋กค ๊ธฐ๋ฐ ์ ๋๋ฉ์ด์
- ๐ง TypeScript: ์์ ํ ํ์ ์์ ์ฑ
- โก ์ต์ ํ: ์ฑ๋ฅ๊ณผ ๋ฉ๋ชจ๋ฆฌ ํจ์จ์ฑ
- ๐ examples/nextjs-example
- ๐ App Router ์ฌ์ฉ
- โจ ๊ธฐ๋ณธ & ๊ณ ๊ธ ์ ๋๋ฉ์ด์ ๋ฐ๋ชจ
- ๐ฏ SSR ์์ ์ฑ ์์ฐ
์คํ ๋ฐฉ๋ฒ:
cd examples/nextjs-example
pnpm install
pnpm dev
# http://localhost:3000์์ ํ์ธ- ๐ examples/vite-example
- โก ๋น ๋ฅธ ๊ฐ๋ฐ ํ๊ฒฝ
- ๐จ Tailwind CSS ์คํ์ผ๋ง
- ๐ฏ ๋ค์ํ ์ฌ์ฉ ์ฌ๋ก
์คํ ๋ฐฉ๋ฒ:
cd examples/vite-example
pnpm install
pnpm dev
# http://localhost:5173์์ ํ์ธ- ๐ examples/remix-example
- ๐ ์ต์ Remix ํ๋ ์์ํฌ
- ๐จ Tailwind CSS ์คํ์ผ๋ง
- ๐ SSR/CSR ์์ ์ฑ ์์ฐ
์คํ ๋ฐฉ๋ฒ:
cd examples/remix-example
pnpm install
pnpm dev
# http://localhost:5173์์ ํ์ธ- ๐ examples/react-router-example
- ๐ฆ ์ต์ React Router 7
- ๐จ Tailwind CSS 4.0 ์คํ์ผ๋ง
- ๐ ํ์ผ ๊ธฐ๋ฐ ๋ผ์ฐํ
์คํ ๋ฐฉ๋ฒ:
cd examples/react-router-example
pnpm install
pnpm dev
# http://localhost:5173์์ ํ์ธ๋ชจ๋ ์์ ์๋ ๋ค์ ๊ธฐ๋ฅ๋ค์ด ํฌํจ๋์ด ์์ต๋๋ค:
- ๐ฌ ์คํฌ๋กค ํธ๋ฆฌ๊ฑฐ ์ ๋๋ฉ์ด์ : ์คํฌ๋กค์ ๋ฐ๋ฅธ ๋ถ๋๋ฌ์ด DotLottie ์ ๋๋ฉ์ด์
- โฏ๏ธ ์๋ ์ฌ์/์ผ์์ ์ง ์ปจํธ๋กค: ์ ๋๋ฉ์ด์ ์๋ ์ ์ด
- ๐ ์ค์๊ฐ ๋๋ฒ๊ทธ ์ ๋ณด: ์ ๋๋ฉ์ด์ ์ํ ์ค์๊ฐ ํ์
- ๐ฑ ๋ฐ์ํ ๋์์ธ: ๋ชจ๋ฐ์ผ ์นํ์ ๋ ์ด์์
- โก ์ฑ๋ฅ ๋ชจ๋ํฐ๋ง: ํ๋ ์๋ฅ ๋ฐ ์ํ ์ถ์
- ๐ ๋ชจ๋ ์ ํ: ์คํฌ๋กค/์๋ ์ ์ด ๋ชจ๋ ํ ๊ธ
- Node.js 16+
- pnpm 8+
git clone <repository-url>
cd pnpm-monorepo
pnpm install# ์ ์ฒด ๋น๋
pnpm build
# ํจํค์ง๋ง ๋น๋
pnpm build:packages
# ์์ ๋ง ๋น๋
pnpm build:examples# ๋ชจ๋ ์์ ์คํ
pnpm dev
# ํน์ ์์ ๋ง ์คํ
cd examples/nextjs-example
pnpm dev- ๐ ์์ ํ ๋ค๊ตญ์ด ์ง์: ๋ชจ๋ ๋๋ฒ๊ทธ ๋ฉ์์ง๊ฐ ํ๊ตญ์ด/์์ด ์ง์
const hook = useLottieScrollTrigger({ debug: true, debugLanguage: "en", // "ko" | "en" });
- ๐ง ES Module ํธํ์ฑ: ๋ชจ๋ ๋ฒ๋ค๋ฌ(Vite, Webpack, esbuild)์์ ์์ ์ ๋์
- ๐ฆ ๋ชจ๋ ํด๊ฒฐ ๊ฐ์ :
gsap/ScrollTrigger๊ฒฝ๋ก๋ก ํ์คํ - ๐ ๏ธ ๊ฐ๋ฐ์ ๊ฒฝํ: ์ธ์ด๋ณ ๋๋ฒ๊ทธ ๋ฉ์์ง๋ก ๋ ๋์ ๊ฐ๋ฐ ๊ฒฝํ
- ๋จ์ํ: DotLottie ์ ์ฉ์ผ๋ก API๊ฐ ํจ์ฌ ๊ฐ๋จํด์ก์ต๋๋ค
- ์ฑ๋ฅ: ๋จ์ผ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ง์์ผ๋ก ๋ฒ๋ค ํฌ๊ธฐ ๊ฐ์
- ์์ ์ฑ: ๋ณต์กํ ํ์ด๋ธ๋ฆฌ๋ ๋ก์ง ์ ๊ฑฐ
- ํ์ ์์ ์ฑ: DotLottie ์ ์ฉ ํ์ ์ผ๋ก ๋ ์ ํํจ
- ํ๋ ์์ํฌ ์ง์: Next.js, Vite, Remix, React Router ์์ ์ง์
mode์ต์ ์ ๊ฑฐ (DotLottie๋ง ์ง์)animationData,path,renderer๋ฑ lottie-web ์ต์ ์ ๊ฑฐlottie-web์์กด์ฑ ์์ ์ ๊ฑฐ
์์ธํ ๋ง์ด๊ทธ๋ ์ด์ ๊ฐ์ด๋๋ CHANGELOG.md๋ฅผ ์ฐธ์กฐํ์ธ์.
- ๐ API ๋ฌธ์
- ๐ ๋ณ๊ฒฝ ๊ธฐ๋ก
- ๐ฏ ์์ ์ฝ๋
- ์ด ์ ์ฅ์๋ฅผ ํฌํฌํ์ธ์
- ๊ธฐ๋ฅ ๋ธ๋์น๋ฅผ ๋ง๋์ธ์ (
git checkout -b feature/amazing-feature) - ๋ณ๊ฒฝ์ฌํญ์ ์ปค๋ฐํ์ธ์ (
git commit -m 'feat: add amazing feature') - ๋ธ๋์น์ ํธ์ํ์ธ์ (
git push origin feature/amazing-feature) - Pull Request๋ฅผ ์ด์ด์ฃผ์ธ์
MIT License - ์์ธํ ๋ด์ฉ์ LICENSE ํ์ผ์ ์ฐธ์กฐํ์ธ์.
- @lottiefiles/dotlottie-react - ํ๋ฅญํ DotLottie React ์ปดํฌ๋ํธ
- GSAP - ๊ฐ๋ ฅํ ์ ๋๋ฉ์ด์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ
- React ์ปค๋ฎค๋ํฐ์ ๋ชจ๋ ๊ธฐ์ฌ์๋ค
๐ก ๊ถ๊ธํ ์ ์ด ์์ผ์๋ฉด Issues์ ๋จ๊ฒจ์ฃผ์ธ์!

