|
| 1 | +import { motion } from "framer-motion"; |
| 2 | +import React from "react"; |
| 3 | + |
| 4 | +// 유틸리티 함수들 |
| 5 | +const getLeafSize = (index: number) => { |
| 6 | + if (index % 3 === 2) { |
| 7 | + return { |
| 8 | + height: "17px", |
| 9 | + width: "23px", |
| 10 | + beforeTop: "12px", |
| 11 | + beforeRight: "1px", |
| 12 | + beforeHeight: "4px", |
| 13 | + beforeWidth: "4px", |
| 14 | + afterHeight: "10px", |
| 15 | + afterWidth: "2px", |
| 16 | + afterLeft: "8px", |
| 17 | + afterTop: "1px", |
| 18 | + }; |
| 19 | + } else if (index % 2 === 1) { |
| 20 | + return { |
| 21 | + height: "11px", |
| 22 | + width: "16px", |
| 23 | + beforeTop: "7px", |
| 24 | + beforeRight: "0px", |
| 25 | + beforeHeight: "3px", |
| 26 | + beforeWidth: "4px", |
| 27 | + afterHeight: "6px", |
| 28 | + afterWidth: "2px", |
| 29 | + afterLeft: "5px", |
| 30 | + afterTop: "1px", |
| 31 | + }; |
| 32 | + } |
| 33 | + return { |
| 34 | + height: "23px", |
| 35 | + width: "30px", |
| 36 | + beforeTop: "17px", |
| 37 | + beforeRight: "1px", |
| 38 | + beforeHeight: "5px", |
| 39 | + beforeWidth: "7px", |
| 40 | + afterHeight: "17px", |
| 41 | + afterWidth: "2px", |
| 42 | + afterLeft: "12px", |
| 43 | + afterTop: "0px", |
| 44 | + }; |
| 45 | +}; |
| 46 | + |
| 47 | +const getLeafGradient = (index: number) => { |
| 48 | + if (index % 4 === 1) { |
| 49 | + return "linear-gradient(to bottom right, #990, #564500)"; |
| 50 | + } else if (index % 2 === 0) { |
| 51 | + return "linear-gradient(to bottom right, #5e9900, #2b5600)"; |
| 52 | + } |
| 53 | + return "linear-gradient(to bottom right, #309900, #005600)"; |
| 54 | +}; |
| 55 | + |
| 56 | +const getLeafDelay = (index: number) => { |
| 57 | + const delays = [1.9, 3.9, 2.3, 4.4, 5, 3.5, 2.8, 1.5, 3.3, 2.5, 1.2, 4.1, 1, 4.7, 3]; |
| 58 | + return delays[index % delays.length]; |
| 59 | +}; |
| 60 | + |
| 61 | +const LeafAnimation: React.FC = () => { |
| 62 | + return ( |
| 63 | + <div className="pointer-events-none fixed inset-0 z-50 overflow-hidden"> |
| 64 | + <motion.div |
| 65 | + className="absolute -top-12 w-full text-right" |
| 66 | + initial={{ opacity: 0 }} |
| 67 | + animate={{ opacity: 1 }} |
| 68 | + transition={{ duration: 1 }} |
| 69 | + > |
| 70 | + {[...Array(15)].map((_, i) => ( |
| 71 | + <motion.i |
| 72 | + key={i} |
| 73 | + className={`relative inline-block opacity-70 ${i % 3 === 1 ? "opacity-50" : ""} ${ |
| 74 | + i % 3 === 2 ? "opacity-30" : "" |
| 75 | + }`} |
| 76 | + style={{ |
| 77 | + height: getLeafSize(i).height, |
| 78 | + width: getLeafSize(i).width, |
| 79 | + background: getLeafGradient(i), |
| 80 | + borderRadius: "5% 40% 70%", |
| 81 | + boxShadow: "inset 0px 0px 1px #222", |
| 82 | + border: "1px solid #333", |
| 83 | + transform: "rotate(180deg)", |
| 84 | + }} |
| 85 | + animate={{ |
| 86 | + x: [300, -350], |
| 87 | + y: [0, 700], |
| 88 | + rotate: [0, 90], |
| 89 | + opacity: [null, 0], |
| 90 | + }} |
| 91 | + transition={{ |
| 92 | + duration: 5, |
| 93 | + repeat: Infinity, |
| 94 | + delay: getLeafDelay(i), |
| 95 | + ease: "easeInOut", |
| 96 | + }} |
| 97 | + > |
| 98 | + <motion.span |
| 99 | + className="absolute" |
| 100 | + style={{ |
| 101 | + content: '""', |
| 102 | + top: getLeafSize(i).beforeTop, |
| 103 | + right: getLeafSize(i).beforeRight, |
| 104 | + height: getLeafSize(i).beforeHeight, |
| 105 | + width: getLeafSize(i).beforeWidth, |
| 106 | + transform: "rotate(49deg)", |
| 107 | + borderRadius: "0% 15% 15% 0%", |
| 108 | + border: "1px solid #222", |
| 109 | + borderLeft: "none", |
| 110 | + background: "linear-gradient(to right, rgba(0,100,0,1), #005600)", |
| 111 | + }} |
| 112 | + /> |
| 113 | + <motion.span |
| 114 | + className="absolute" |
| 115 | + style={{ |
| 116 | + content: '""', |
| 117 | + height: getLeafSize(i).afterHeight, |
| 118 | + width: getLeafSize(i).afterWidth, |
| 119 | + background: "linear-gradient(to right, rgba(0,0,0,.15), rgba(0,0,0,0))", |
| 120 | + transform: "rotate(125deg)", |
| 121 | + left: getLeafSize(i).afterLeft, |
| 122 | + top: getLeafSize(i).afterTop, |
| 123 | + borderRadius: "50%", |
| 124 | + }} |
| 125 | + /> |
| 126 | + </motion.i> |
| 127 | + ))} |
| 128 | + </motion.div> |
| 129 | + </div> |
| 130 | + ); |
| 131 | +}; |
| 132 | + |
| 133 | +export default LeafAnimation; |
0 commit comments