21st.dev Magic MCP — AI-powered UI component generation via natural language. Access to 21st.dev component library, SVGL brand logos, and real-time preview. Generate React/Tailwind components with /ui command.
中文简介正在准备中。当前显示原文说明。
Framer Motion React animation library skill — declarative animations, gestures, layout transitions, scroll-triggered animations, variants, AnimatePresence, and performance optimization.
中文简介正在准备中。当前显示原文说明。
查看安装方法安装前可以查看交给 AI 代理的指令内容。
Framer Motion is a production-ready animation library for React. Simple declarative API, powerful layout animations, gestures, and server-side rendering support.
Version: 12.40.0
Package: framer-motion
License: MIT
npm install framer-motion
# or
yarn add framer-motion
# or
pnpm add framer-motion
motion ComponentEvery HTML/SVG element becomes animatable by prefixing with motion.:
import { motion } from "framer-motion"
<motion.div
animate={{ x: 100, opacity: 1 }}
initial={{ x: 0, opacity: 0 }}
transition={{ duration: 0.5 }}
/>
Wrap components that conditionally render to animate their removal:
import { AnimatePresence, motion } from "framer-motion"
<AnimatePresence>
{isVisible && (
<motion.div
initial={{ opacity: 0, scale: 0.8 }}
animate={{ opacity: 1, scale: 1 }}
exit={{ opacity: 0, scale: 0.8 }}
transition={{ duration: 0.3 }}
>
Content
</motion.div>
)}
</AnimatePresence>
Define named animation states for cleaner code:
const variants = {
hidden: { opacity: 0, y: 20 },
visible: { opacity: 1, y: 0 },
exit: { opacity: 0, y: -20 }
}
<motion.div
variants={variants}
initial="hidden"
animate="visible"
exit="exit"
/>
<motion.button
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
transition={{ type: "spring", stiffness: 400, damping: 17 }}
>
Click Me
</motion.button>
<motion.div
drag
dragConstraints={{ left: 0, right: 300, top: 0, bottom: 300 }}
whileDrag={{ scale: 1.1, boxShadow: "0 10px 30px rgba(0,0,0,0.2)" }}
/>
Automatically animate layout changes:
<motion.div layout>
{/* Content that changes size/position */}
</motion.div>
// Shared layout animation (morphing between elements)
<motion.div layoutId="shared-element">
{selected ? <ExpandedView /> : <CompactView />}
</motion.div>
import { useScroll, useTransform, motion } from "framer-motion"
function ParallaxSection() {
const { scrollYProgress } = useScroll()
const scale = useTransform(scrollYProgress, [0, 1], [0.8, 1])
const opacity = useTransform(scrollYProgress, [0, 0.5, 1], [0, 1, 1])
return <motion.div style={{ scale, opacity }}>Content</motion.div>
}
// Scroll-linked progress bar
function ProgressBar() {
const { scrollYProgress } = useScroll()
return <motion.div style={{ scaleX: scrollYProgress, transformOrigin: "left" }} />
}
whileInView (Intersection Observer)Animate elements when they enter the viewport:
<motion.div
initial={{ opacity: 0, y: 40 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true, margin: "-50px" }}
transition={{ duration: 0.6 }}
>
Appears on scroll
</motion.div>
const container = {
hidden: { opacity: 0 },
visible: {
opacity: 1,
transition: { staggerChildren: 0.1, delayChildren: 0.2 }
}
}
const item = {
hidden: { opacity: 0, y: 20 },
visible: { opacity: 1, y: 0 }
}
<motion.ul variants={container} initial="hidden" animate="visible">
{items.map(item => (
<motion.li key={item.id} variants={item}>{item.text}</motion.li>
))}
</motion.ul>
// With Next.js App Router (template.tsx)
import { motion } from "framer-motion"
export default function Template({ children }: { children: React.ReactNode }) {
return (
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -20 }}
transition={{ duration: 0.3 }}
>
{children}
</motion.div>
)
}
Spring animations feel more natural than duration-based:
<motion.div
animate={{ x: 100 }}
transition={{
type: "spring",
stiffness: 100, // Spring strength (default: 100)
damping: 10, // Resistance (default: 10)
mass: 1, // Object weight (default: 1)
bounce: 0.25 // Bounciness (0-1)
}}
/>
// Preset springs
transition={{ type: "spring", stiffness: 300, damping: 30 }} // Snappy
transition={{ type: "spring", stiffness: 50, damping: 20 }} // Bouncy
<motion.div
animate={{
x: [0, 100, 50, 100, 0],
scale: [1, 1.2, 0.9, 1.1, 1],
rotate: [0, 0, 270, 270, 0]
}}
transition={{ duration: 2, repeat: Infinity }}
/>
layout="position" Instead of layoutWhen only position changes (not size):
<motion.div layout="position" />
useReducedMotionRespect accessibility preferences:
import { useReducedMotion } from "framer-motion"
const shouldReduceMotion = useReducedMotion()
<motion.div
animate={shouldReduceMotion ? {} : { x: 100 }}
transition={{ duration: 0.5 }}
/>
Animate only transform and opacity for 60fps:
x, y, scale, rotate, opacitywidth, height, top, left, backgroundColorimport { m } from "framer-motion" // Smaller bundle
// Use m.div instead of motion.div
<m.div animate={{ opacity: 1 }} />
will-change Hint<motion.div style={{ willChange: "transform" }} />
<AnimatePresence> for proper exit animationsviewport={{ once: true }} on scroll animations to avoid re-triggeringexit prop when using conditional renderingprefers-reduced-motion for accessibilitylayoutId for shared element transitions between pages// Visualize layout animations
<motion.div layout layoutRoot />
// Log animation lifecycle
<motion.div
onAnimationStart={() => console.log("started")}
onAnimationComplete={() => console.log("completed")}
/>
| Issue | Fix |
|---|---|
| Layout animation jitter | Add layoutId to animating elements |
| Exit animation not playing | Wrap with <AnimatePresence> |
| Children not staggering | Put staggerChildren on container's transition |
| Transform origin off | Set style={{ originX: 0.5, originY: 0.5 }} |
| Hover state flickering | Use whileHover not CSS :hover |
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
21st.dev Magic MCP — AI-powered UI component generation via natural language. Access to 21st.dev component library, SVGL brand logos, and real-time preview. Generate React/Tailwind components with /ui command.
中文简介正在准备中。当前显示原文说明。
AES CBC/ECB modlarına karşı kriptografik bütünlük saldırıları — bit flipping, IV manipulation, ECB cut-and-paste, CBC-MAC length extension, IV reuse
中文简介正在准备中。当前显示原文说明。
AES-GCM ve ChaCha20-Poly1305 nonce yeniden kullanımı saldırısı — GF(2^128) polinom kök bulma ile Hash Key kurtarma ve MAC sahteciliği.
中文简介正在准备中。当前显示原文说明。
tespit etmeabnormal access patterns in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics. Identifies after-hours bulk downloads, access from new IP addresses, unusual API calls (GetObject spikes), and potential data exfiltration using statistical baselines and time-series anomaly Tespit.
中文简介正在准备中。当前显示原文说明。
Perform static and symbolic analysis of Solidity smart contracts using Slither and Mythril to tespit etmereentrancy, integer overflow, access control, and other vulnerability classes before Dağıt:ment to Ethereum mainnet.
中文简介正在准备中。当前显示原文说明。
Parses Kubernetes API server audit logs (JSON lines) to tespit etmeexec-into-pod, secret access, RBAC modifications, privileged pod creation, and anonymous API access. Builds threat Tespit rules from audit event patterns. Use investigating yaparken Kubernetes cluster compromise or building k8s-specific SIEM Tespit rules.
中文简介正在准备中。当前显示原文说明。