-
according to documentation there should be some way to attach a callback to a custom animation but there is little information on how to implement such callback currently I have this custom animation export const PermissionExiting = (values) => { used like this
how would I attach a callback to the exiting animation? unlike remade animations .withCallback() is not working |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hey, probably here: const callback = (finished: boolean) => { /* animation ended or has been cancelled */ } |
Beta Was this translation helpful? Give feedback.
-
This is an old question, but in case someone is looking for an answer, here it is: function SomeAwesomeComponent() {
return (
<Animated.View
collapsable={false}
entering={CustomEnteringAnimation(() => {
// your callback
})}
>
{/* Your content */}
</Animated.View>
);
}
function CustomEnteringAnimation(callback: () => void) {
return () => {
"worklet";
return {
animations: {
opacity: withTiming(1),
transform: [
{
scale: withTiming(1)
},
{
translateY: withTiming(1)
}
]
},
initialValues: {
transform: [{ scale: 0 }, { translateY: 200 }],
opacity: 0
},
callback: (finished: boolean) => {
if (finished) {
runOnJS(callback)();
}
}
};
};
} |
Beta Was this translation helpful? Give feedback.
This is an old question, but in case someone is looking for an answer, here it is: