I am would like to make an animated header.
onScroll
function to update the animated value. The animation works fine, but the animation is not smooth at all.
I saw this issue of how using scrollEventThrottle
helps the smoothness. So I thought using FlatList would be smooth but it's not. If your scroll while pressing, it's smooth. But if you scroll and leave the finger, it's jumpy ( I don't know how to describe it. Sorry). The scrolling is smooth but the animated view (Header) animation is not smooth at all.
Environment
Target Platform: iOS and Android
Build tools: expo
Update
So, I tried to implement the same functionality using ScrollView. However, I think, its event worse using ScrollView when compared to FlatList.
Here is the expo snack demo: Animated ScrollView Header
I think I need to mention how I got here at the first place. So, I tried to implement this by a very nice tutorial in Medium, and also by watching this awesome youtube react conf viedo by Brent. However, the exact code used on youtube video has the same effect. Also, on the Medium tutorial, the author has given a Link to his expo Animated header link, which works very smoothly. But the same code doesn't work smoothly when I copy paste the code. So, I think the problem is with the react or react native version. I will update if I have any new update. Thank you.
There has been a regression in React Native 0.46 which, fortunately, has been fixed in 0.48.2 (see this issue and this PR). That's why you're having the issue with recent Expo versions. I've had this problem with custom parallax images, and this was solved by building a custom binary with RN 0.48.3.
Your code is fine, even though I would recommend setting scrollEventThrottle
to 1
as this really helps smoothing things out on iOS.