Skip to content

Commit

Permalink
fix: Fixed recipe reveal animation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
TiagoRibeiro25 committed Aug 25, 2023
1 parent 8232b27 commit 37dc941
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/components/Recipe/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,22 @@ interface RecipeProps {
animation?: Animation | 'none';
}

function getRevealAnimation(index: number | undefined) {
if (index === undefined) return 'slide-bottom';
return index % 2 === 0 ? 'slide-left' : 'slide-right';
}

const Recipe: React.FC<RecipeProps> = ({ recipe, index, className, animation }) => {
const recipesContext = useContext(RecipesContext);

const getRevealAnimation = (index: number | undefined): Animation | undefined => {
if (index === undefined) return 'slide-bottom';
return index % 2 === 0 ? 'slide-left' : 'slide-right';
};

return (
<div className={classNames('rounded lg:w-[374px] w-full mb-6 lg:mb-0', className)}>
<Reveal
animation={animation !== 'none' ? animation : getRevealAnimation(index)}
animation={
animation !== 'none' && animation !== undefined
? animation
: getRevealAnimation(index)
}
width="100%"
delay={0.15}
noAnimation={animation === 'none'}
Expand Down

0 comments on commit 37dc941

Please sign in to comment.