HwangTaehyun / react-native-lottie-splash-screen

⚡ Lottie splash screen for your react native app!
MIT License
222 stars 62 forks source link

How can i know when the lottie animation has ended. #23

Closed duchavmodev closed 2 years ago

duchavmodev commented 2 years ago

I need to show some animation on the Home screen when the user open the app But currently, the lottie animation is long and it overlaps the animation on the Home screen So how can I know whether the lottie animation has ended or not Something like: RNSplashScreen.addEventListender('onEnd', doTheHomeScreenAnimation)

HwangTaehyun commented 2 years ago

@duchavmodev Sorry for my late reply. It would be nice to have this feature. However, in this situation, i would suggest this in ios project.

Firstly, you put below code in native part.

https://github.com/HwangTaehyun/react-native-lottie-splash-screen#:~:text=//%20If%20you%20want%20the%20animation%20layout%20to%20be%20forced%20to%20remove%20when%20hide%20is%20called%2C%20use%20this%20code%0A%20%20%5BRNSplashScreen%20setAnimationFinished%3Atrue%5D%3B

Then, in react-native, you should call this function in useEffect of App.ts

import SplashScreen from 'react-native-lottie-splash-screen';
...
const App = ()=> {
...
    useEffect(() => {
        SplashScreen.hide();
    },[])
...
}