Skip to content

Commit

Permalink
fix: types
Browse files Browse the repository at this point in the history
  • Loading branch information
catalinmiron committed Nov 14, 2023
1 parent e90a633 commit 821b5e1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function App() {
stagger={50}
duration={300}
exitDirection={-1}
entering={() => ZoomInEasyDown.springify()}
entering={() => ZoomInEasyDown}
exiting={() => FadeOutDown.springify()}
style={{
flexDirection: 'row',
Expand Down
20 changes: 16 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import Animated, {
Layout,
} from 'react-native-reanimated';
import type { ViewStyle } from 'react-native';
import type { BaseAnimationBuilder, Keyframe } from 'react-native-reanimated';
import type { EntryExitAnimationFunction } from 'react-native-reanimated';

export type StaggerProps = React.PropsWithChildren<{
stagger?: number;
Expand Down Expand Up @@ -37,7 +39,12 @@ export type StaggerProps = React.PropsWithChildren<{
* Keyframes animations: https://www.reanimated2.com/docs/api/LayoutAnimations/keyframeAnimations
*
*/
entering?: () => ComplexAnimationBuilder;
entering?: () =>
| ComplexAnimationBuilder
| BaseAnimationBuilder
| typeof BaseAnimationBuilder
| EntryExitAnimationFunction
| Keyframe;
/**
* Return the desired animation builder. It can be any of
* https://www.reanimated2.com/docs/api/LayoutAnimations/exitAnimations.
Expand All @@ -47,7 +54,12 @@ export type StaggerProps = React.PropsWithChildren<{
* Keyframes animations: https://www.reanimated2.com/docs/api/LayoutAnimations/keyframeAnimations
*
*/
exiting?: () => ComplexAnimationBuilder;
exiting?: () =>
| ComplexAnimationBuilder
| BaseAnimationBuilder
| typeof BaseAnimationBuilder
| EntryExitAnimationFunction
| Keyframe;

initialEnteringDelay?: number;
initialExitingDelay?: number;
Expand Down Expand Up @@ -78,15 +90,15 @@ export function Stagger({
<Animated.View
key={child.key ?? index}
layout={Layout}
entering={entering()
entering={(entering() as ComplexAnimationBuilder)
.delay(
initialEnteringDelay +
(enterDirection === 1
? index * stagger
: (React.Children.count(children) - index) * stagger)
)
.duration(duration)}
exiting={exiting()
exiting={(exiting() as ComplexAnimationBuilder)
.delay(
initialExitingDelay +
(exitDirection === 1
Expand Down

0 comments on commit 821b5e1

Please sign in to comment.