Commit 08186cd0 by HoMeTown

feat: 完善navbar的展开收起

parent f229ff56
...@@ -17,9 +17,13 @@ interface MainLayoutProps { ...@@ -17,9 +17,13 @@ interface MainLayoutProps {
} }
const contentVariants = { const contentVariants = {
hidden: { navTween: {
x: '-100%', // 向左移出屏幕 x: '-90px', // 向左移出屏幕
transition: { type: 'tween', duration: 0.3 }, transition: { type: 'tween', duration: 0.3, ease: 'easeInOut' },
},
mainTween: {
x: '-60px', // 向左移出屏幕
transition: { type: 'tween', duration: 0.3, ease: 'easeInOut' },
}, },
expanded: { expanded: {
width: '90px', width: '90px',
...@@ -57,7 +61,7 @@ export const MainLayout: React.FC<MainLayoutProps> = ({ children }) => { ...@@ -57,7 +61,7 @@ export const MainLayout: React.FC<MainLayoutProps> = ({ children }) => {
<motion.main className={styles.layoutMain}> <motion.main className={styles.layoutMain}>
{/* hidden */} {/* hidden */}
<motion.div <motion.div
animate={isNavBarVisible ? isHistoryVisible ? 'shrunk' : 'expanded' : 'hidden'} animate={isNavBarVisible ? isHistoryVisible ? 'shrunk' : 'expanded' : 'navTween'}
variants={contentVariants} variants={contentVariants}
className={`fixed right-[-12px] top-[10px] z-[49] h-auto sm:relative flex sm:h-full pl-[12px] items-center ${isHistoryVisible && !isMobile() ? 'w-[340px]' : 'w-[90px]'} box-border`} className={`fixed right-[-12px] top-[10px] z-[49] h-auto sm:relative flex sm:h-full pl-[12px] items-center ${isHistoryVisible && !isMobile() ? 'w-[340px]' : 'w-[90px]'} box-border`}
> >
...@@ -87,6 +91,8 @@ export const MainLayout: React.FC<MainLayoutProps> = ({ children }) => { ...@@ -87,6 +91,8 @@ export const MainLayout: React.FC<MainLayoutProps> = ({ children }) => {
)} )}
</motion.div> </motion.div>
<motion.div <motion.div
variants={contentVariants}
animate={isNavBarVisible ? '' : 'mainTween'}
className={`${styles.layoutContent}`} className={`${styles.layoutContent}`}
> >
{children} {children}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment