From 12e3722c541977f0f23514535b5f14746d54acd8 Mon Sep 17 00:00:00 2001 From: KQL Date: Mon, 8 Sep 2025 05:39:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E9=9D=A2=E8=AF=95?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=8A=A8=E7=94=BB=E7=9A=84=E5=B1=95=E5=BC=80?= =?UTF-8?q?=E5=92=8C=E6=94=B6=E8=B5=B7=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加expanding和collapsing动画类 - 使用cubic-bezier缓动函数让动画更平滑 - 收起时等待动画完成后再隐藏组件 - 动画容器添加缩放效果增强视觉体验 - 分离展开和收起动画的时间和效果 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../InterviewStatusAnimation/index.css | 34 +++++++++++++++++-- .../InterviewStatusAnimation/index.jsx | 24 ++++++++++--- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/src/pages/CompanyJobsPage/components/InterviewStatusAnimation/index.css b/src/pages/CompanyJobsPage/components/InterviewStatusAnimation/index.css index ab7acd3..c0a0fed 100644 --- a/src/pages/CompanyJobsPage/components/InterviewStatusAnimation/index.css +++ b/src/pages/CompanyJobsPage/components/InterviewStatusAnimation/index.css @@ -1,20 +1,42 @@ .interview-status-animation-wrapper { width: 100%; - padding: 10px 0; background: linear-gradient(135deg, #f7faff 0%, #ffffff 100%); border-top: 1px solid #e5e6eb; - animation: slideDown 0.3s ease-out; overflow: hidden; + transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); } -@keyframes slideDown { +.interview-status-animation-wrapper.expanding { + animation: expandDown 0.4s ease-out forwards; +} + +.interview-status-animation-wrapper.collapsing { + animation: collapseUp 0.3s ease-in forwards; +} + +@keyframes expandDown { from { max-height: 0; opacity: 0; + padding: 0; } to { max-height: 200px; opacity: 1; + padding: 10px 0; + } +} + +@keyframes collapseUp { + from { + max-height: 200px; + opacity: 1; + padding: 10px 0; + } + to { + max-height: 0; + opacity: 0; + padding: 0; } } @@ -25,6 +47,12 @@ align-items: center; justify-content: center; overflow: hidden; + transform: scale(0.9); + transition: transform 0.3s ease; +} + +.interview-status-animation-wrapper.expanding .animation-container { + transform: scale(1); } .animation-container svg { diff --git a/src/pages/CompanyJobsPage/components/InterviewStatusAnimation/index.jsx b/src/pages/CompanyJobsPage/components/InterviewStatusAnimation/index.jsx index 679950d..0f14ab6 100644 --- a/src/pages/CompanyJobsPage/components/InterviewStatusAnimation/index.jsx +++ b/src/pages/CompanyJobsPage/components/InterviewStatusAnimation/index.jsx @@ -21,6 +21,22 @@ export default ({ statusText, isOpen }) => { const animationContainer = useRef(null); const lottieInstance = useRef(null); const [animationData, setAnimationData] = useState(null); + const [isVisible, setIsVisible] = useState(false); + const [animationClass, setAnimationClass] = useState(''); + + useEffect(() => { + if (isOpen) { + setIsVisible(true); + setAnimationClass('expanding'); + } else if (isVisible) { + setAnimationClass('collapsing'); + const timer = setTimeout(() => { + setIsVisible(false); + setAnimationClass(''); + }, 300); // 等待收起动画完成 + return () => clearTimeout(timer); + } + }, [isOpen, isVisible]); useEffect(() => { if (isOpen && statusText) { @@ -35,7 +51,7 @@ export default ({ statusText, isOpen }) => { }, [isOpen, statusText]); useEffect(() => { - if (animationData && animationContainer.current && isOpen) { + if (animationData && animationContainer.current && isVisible) { // 清除之前的动画实例 if (lottieInstance.current) { lottieInstance.current.destroy(); @@ -56,12 +72,12 @@ export default ({ statusText, isOpen }) => { } }; } - }, [animationData, isOpen]); + }, [animationData, isVisible]); - if (!isOpen) return null; + if (!isVisible) return null; return ( -
+
);