팍 사라지는게 아니고 스르륵 사라져벌임
import { motion, AnimatePresence } from "motion/react";
import { useState } from "react";
const FadeExample = () => {
const [isVisible, setIsVisible] = useState(false);
const fadeVariants = {
initial: { opacity: 0 },
animate: { opacity: 1 },
exit: { opacity: 0 }
};
return (
<div>
<button onClick={() => setIsVisible(!isVisible)}>
{isVisible ? "숨기기" : "보이기"}
</button>
<AnimatePresence>
{isVisible && (
<motion.div
variants={fadeVariants}
initial="initial"
animate="animate"
exit="exit"
style={{
width: 200,
height: 200,
backgroundColor: "blue",
marginTop: 20
}}
>
페이드 애니메이션
</motion.div>
)}
</AnimatePresence>
</div>
);
};
'라이브러리 > framer-motion' 카테고리의 다른 글
[framer-motion] 여러개의 애니메이션 연속적으로 실행시키기 (1) | 2025.07.25 |
---|---|
[framer-motion] 페이지 전환 애니메이션 (0) | 2024.08.11 |
[트러블 슈팅 / framer-motion] onViewportEnter 뷰포트 감지 버그 해결 (1) | 2024.06.09 |
[framer-motion] 뷰포트 인-아웃 감지 (1) | 2024.06.09 |
[framer-motion] 조건부 애니메이션 (0) | 2024.06.09 |