r/reactnative • • Nov 25 '19

https://github.com/tienph6m/react-native-animated-spinkit - A pure JavaScript port of SpinKit for React Native

286 Upvotes

34 comments sorted by

8

u/tienph6m Nov 25 '19 edited Nov 28 '19

3

u/vertigo_101 Nov 25 '19

Amazing work

2

u/tienph6m Nov 25 '19

Thanks man ;)

3

u/manoylo_vnc Nov 25 '19

Sweet! I’ll test it out in my project today. Thanks for sharing!

1

u/tienph6m Nov 25 '19

Thanks! Let me know if there is any problem :)

1

u/WillBackUpWithSource Nov 25 '19

Interesting. Might replace this in my current project.

Works great on both iOS and Android?

1

u/tienph6m Nov 25 '19

Yes, it works on both Android and iOS. It's not as fast as the native module (react-native-spinkit), but it's still pretty fast since all animations run on the UI thread (by using useNativeDriver). Let me know if there is any problem ;)

1

u/chazzox Nov 25 '19

really cool. I hope to use it in my upcoming project!

1

u/tienph6m Nov 26 '19

Thanks ;)

1

u/EskimoEmoji Nov 25 '19 edited Nov 25 '19

This is sweet. Is there a way to replace the Flatlist activity indicator with these?

2

u/tienph6m Nov 26 '19

Hi, I'm not sure what you mean by "FlatList activity indicator". You can use these like React Native's ActivityIndicator, in a list you would probably want to show one of these when the list is empty and loading. If you're talking about RefreshControl, this library alone isn't enough since a refresh control does a lot more than just showing/hiding a loading indicator.

1

u/Nikosssgr Nov 25 '19

Why didn't you use react native reanimated instead?

4

u/tienph6m Nov 26 '19 edited Nov 26 '19

Good question. I think reanimated really shines when it's used with react-native-gesture-handler or when you're doing some animations that can't run entirely on the UI thread with Animated. Since I was able to make all the animations run on the UI thread with Animated's native driver, I don't see any real benefits of using reanimated and the library would have to require an extra native dependency.

1

u/hello_Mrs_Cumberdale Nov 26 '19

The benefit of reanimated here is that it would've let you loop animations without ever going back to JS, so you could potentially do work that blocks the JS thread without affecting the loading animation.

2

u/tienph6m Nov 26 '19 edited Nov 26 '19

https://facebook.github.io/react-native/docs/animated#loop

Will loop without blocking the UI thread if the child animation is set to useNativeDriver: true

I believe that's not the case. On the other hand, stagger, parallel and sequence will block the JS thread. But I was able to make the animations run entirely on the UI thread by not using sequence (I implemented a custom easing function to achieve the same effect), and the use of stagger, parallel in this library only affects the JS thread at the beginning of the animation, after that loop will care of the rest.

1

u/hello_Mrs_Cumberdale Nov 26 '19

Oh awesome, I didn't know about loop. Nevermind then!

2

u/[deleted] Nov 26 '19

This is the right answer. rn-reanimated isn’t just blanketly better every time.

1

u/Nikosssgr Nov 26 '19

Indeed for transform and opacity animations, native driver suffices. Thanks for the explanation.

1

u/Tom_Ov_Bedlam Nov 26 '19

Really nice

1

u/tienph6m Nov 26 '19

Thanks man!

1

u/[deleted] Nov 26 '19

Looks great!

1

u/tienph6m Nov 26 '19

Thank you!

1

u/newoYelda Nov 26 '19

Love animations, but what would be an advantage of this over using a LottieWrapper?

2

u/tienph6m Nov 26 '19

This doesn't require any extra native dependencies. Another than that I don't know because I don't use Lottie myself. It is a really cool project but it seems like a lot and I wouldn't want to add it to my project just for some loading animations. If you're already using lottie and not noticing any perf issues then I'd say keep using it ;)

1

u/iamshadmirza Nov 26 '19

Super awesome

2

u/tienph6m Nov 26 '19

Thanks dude!

1

u/olkunmustafa Nov 26 '19

Perfect Animations. Thank you

1

u/tienph6m Nov 26 '19

Thanks man!

1

u/jones-macallan Dec 02 '19

Great work. Just to be clear, this cannot be used with an Expo app?

2

u/tienph6m Dec 02 '19

You can definitely use this in Expo apps, it's a port written in pure JavaScript.

0

u/[deleted] Nov 26 '19

[deleted]