diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-15 14:52:16 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-15 14:52:16 +0700 |
| commit | 4e634a9d3556e94c7ce0729ef9f15b73495b2e28 (patch) | |
| tree | 1f04e5bb360ea4801dfc47a58354ff21b93b34a1 /src/core/components/layouts | |
| parent | 3b19ddcd0051f094b4659a35107646d678c2fd0c (diff) | |
product detail desktop
Diffstat (limited to 'src/core/components/layouts')
| -rw-r--r-- | src/core/components/layouts/AnimationLayout.jsx | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/core/components/layouts/AnimationLayout.jsx b/src/core/components/layouts/AnimationLayout.jsx index c4dee606..7acf21dc 100644 --- a/src/core/components/layouts/AnimationLayout.jsx +++ b/src/core/components/layouts/AnimationLayout.jsx @@ -1,20 +1,32 @@ +import useDevice from '@/core/hooks/useDevice' import { motion } from 'framer-motion' const AnimationLayout = ({ children, ...props }) => { - const transition = { - ease: 'easeIn', - duration: 0.2 + const { isMobile } = useDevice() + + const initialConfig = { + opacity: 0, + x: 0, + y: 0 + } + + const animateConfig = { + opacity: 1, + x: 0, + y: 0, + transition: { duration: 0.2, delay: 0.2, ease: 'easeInOut' } + } + + const exitConfig = { + opacity: 0, + x: isMobile ? 30 : 0, + y: 0, + transition: { duration: 0.2, ease: 'easeInOut' } } return ( children && ( - <motion.main - initial={{ opacity: 0, x: 0, y: 0 }} - animate={{ opacity: 1, x: 0, y: 0 }} - exit={{ opacity: 0, x: 30, y: 0 }} - transition={transition} - {...props} - > + <motion.main initial={initialConfig} animate={animateConfig} exit={exitConfig} {...props}> {children} </motion.main> ) |
