Skip to content

Commit

Permalink
feat(project): add slide from right to animation
Browse files Browse the repository at this point in the history
  • Loading branch information
RCVZ committed Jul 22, 2021
1 parent 8fb1cd3 commit a65552b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/Animation/Slide/Slide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,24 @@ type Props = {
onOpenAnimationEnd?: () => void;
onCloseAnimationEnd?: () => void;
children: ReactNode;
fromRight?: boolean;
};

const Slide = ({ open = true, duration = 250, delay = 0, onOpenAnimationEnd, onCloseAnimationEnd, children }: Props): JSX.Element | null => {
const Slide = ({
open = true,
duration = 250,
delay = 0,
onOpenAnimationEnd,
onCloseAnimationEnd,
children,
fromRight,
}: Props): JSX.Element | null => {
const seconds = duration / 1000;
const transition = `transform ${seconds}s ease-out`; // todo: -webkit-transform;
const createStyle = (status: Status): CSSProperties => ({
transition,
transform: status === 'opening' || status === 'open' ? 'translateY(0)' : 'translateY(15px)',
transform: status === 'opening' || status === 'open' ? 'translateY(0)' : `${fromRight ? 'translateX(15px)' : 'translateY(15px)'}`,
zIndex: 15,
});

return (
Expand Down

0 comments on commit a65552b

Please sign in to comment.