Separate Client Portal & Dashboard

This commit is contained in:
2022-05-23 10:38:16 +07:00
parent f2e84e6244
commit 89bb57f357
569 changed files with 60252 additions and 280 deletions

View File

@@ -0,0 +1,50 @@
import { useEffect } from 'react';
import { m, useAnimation, MotionProps } from 'framer-motion';
import { useInView } from 'react-intersection-observer';
// @mui
import { Box, BoxProps } from '@mui/material';
// ----------------------------------------------------------------------
type Props = BoxProps & MotionProps;
interface MotionInViewProps extends Props {
threshold?: number | number[];
}
export default function MotionInView({
children,
variants,
transition,
threshold,
...other
}: MotionInViewProps) {
const controls = useAnimation();
const [ref, inView] = useInView({
threshold: threshold || 0,
triggerOnce: true,
});
useEffect(() => {
if (!variants) return;
if (inView) {
controls.start(Object.keys(variants)[1]);
} else {
controls.start(Object.keys(variants)[0]);
}
}, [controls, inView, variants]);
return (
<Box
ref={ref}
component={m.div}
initial={variants ? Object.keys(variants)[0] : false}
animate={controls}
variants={variants}
transition={transition}
{...other}
>
{children}
</Box>
);
}