@@ -36,15 +36,19 @@ export function Animation(props: {
3636 disabled ?: boolean ;
3737} ) : React . ReactElement ;
3838
39- export function Animation ( props : AnimationProps ) : React . ReactElement | null {
39+ export function Animation ( {
40+ tween,
41+ children,
42+ disabled = false ,
43+ } : AnimationProps ) : React . ReactElement | null {
4044 const ref = React . useRef < HTMLElement > ( null ) ;
4145 const id = React . useId ( ) ;
4246
4347 const { timeline } = useScrollytelling ( ) ;
4448 const { getTimelineSpace } = useDispatcher ( ) ;
4549
4650 React . useEffect ( ( ) => {
47- if ( ! timeline || ! props . tween || props . disabled ) return ;
51+ if ( ! timeline || ! tween || disabled ) return ;
4852
4953 const addTweenToTimeline = (
5054 tween : TweenWithChildrenDef | TweenWithTargetDef
@@ -75,24 +79,24 @@ export function Animation(props: AnimationProps): React.ReactElement | null {
7579 } else return ( ) => undefined ;
7680 } ;
7781
78- if ( Array . isArray ( props . tween ) ) {
79- const cleanupTweens = props . tween . map ( ( tween ) => {
82+ if ( Array . isArray ( tween ) ) {
83+ const cleanupTweens = tween . map ( ( tween ) => {
8084 const cleanup = addTweenToTimeline ( tween ) ;
8185 return cleanup ;
8286 } ) ;
8387 return ( ) => {
8488 cleanupTweens . forEach ( ( cleanup ) => cleanup ?.( ) ) ;
8589 } ;
8690 } else {
87- const cleanup = addTweenToTimeline ( props . tween ) ;
91+ const cleanup = addTweenToTimeline ( tween ) ;
8892 return ( ) => {
8993 cleanup ?.( ) ;
9094 } ;
9195 }
92- } , [ getTimelineSpace , id , props . tween , timeline , props . disabled ] ) ;
96+ } , [ getTimelineSpace , id , tween , timeline , disabled ] ) ;
9397
94- if ( props . children ) {
95- return < Slot ref = { ref } > { props . children } </ Slot > ;
98+ if ( children ) {
99+ return < Slot ref = { ref } > { children } </ Slot > ;
96100 }
97101 return null ;
98102}
0 commit comments