Skip to content

Commit

Permalink
feat: added enabled prop
Browse files Browse the repository at this point in the history
  • Loading branch information
osama jamil authored and osama jamil committed Sep 25, 2023
1 parent e90a633 commit ff29e92
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import Animated, {
import type { ViewStyle } from 'react-native';

export type StaggerProps = React.PropsWithChildren<{
enabled?: boolean;
/**
* to enable or disable the stagger animation
*/
stagger?: number;
/**
* The direction of the enter animation.
Expand Down Expand Up @@ -54,6 +58,7 @@ export type StaggerProps = React.PropsWithChildren<{
}>;
export function Stagger({
children,
enabled = true,
stagger = 50,
enterDirection = 1,
exitDirection = -1,
Expand All @@ -68,6 +73,10 @@ export function Stagger({
return null;
}

if (!enabled) {
return <Animated.View style={style}>{children}</Animated.View>;
}

return (
<Animated.View style={style} layout={Layout}>
{React.Children.map(children, (child, index) => {
Expand Down Expand Up @@ -101,4 +110,4 @@ export function Stagger({
})}
</Animated.View>
);
}
}

0 comments on commit ff29e92

Please sign in to comment.