11import { StyleSheet , type ViewProps , type ViewStyle } from 'react-native' ;
22import NativeEaseView from './EaseViewNativeComponent' ;
3- import type { AnimateProps , Transition } from './types' ;
3+ import type { AnimateProps , Transition , TransitionEndEvent } from './types' ;
44
55export type EaseViewStyle = Omit < ViewStyle , 'opacity' | 'transform' > ;
66
@@ -19,6 +19,8 @@ export type EaseViewProps = Omit<ViewProps, 'style'> & {
1919 initialAnimate ?: AnimateProps ;
2020 /** Animation configuration (timing or spring). */
2121 transition ?: Transition ;
22+ /** Called when a property's animation ends. Reports which property and whether it finished naturally or was interrupted. */
23+ onTransitionEnd ?: ( event : TransitionEndEvent ) => void ;
2224 /**
2325 * Use a hardware layer during animations on Android for smoother rendering.
2426 * The view is rasterized to a GPU texture while animating so property changes
@@ -35,6 +37,7 @@ export function EaseView({
3537 animate,
3638 initialAnimate,
3739 transition,
40+ onTransitionEnd,
3841 useHardwareLayer = true ,
3942 style,
4043 ...rest
@@ -77,9 +80,15 @@ export function EaseView({
7780 const transitionLoop =
7881 transition ?. type === 'timing' ? transition . loop ?? 'none' : 'none' ;
7982
83+ const handleTransitionEnd = onTransitionEnd
84+ ? ( event : { nativeEvent : { property : string ; finished : boolean } } ) =>
85+ onTransitionEnd ( event . nativeEvent as TransitionEndEvent )
86+ : undefined ;
87+
8088 return (
8189 < NativeEaseView
8290 style = { cleanStyle }
91+ onTransitionEnd = { handleTransitionEnd }
8392 animateOpacity = { resolved . opacity }
8493 animateTranslateX = { resolved . translateX }
8594 animateTranslateY = { resolved . translateY }
0 commit comments