question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using the Animated.Flatlist or Animated.ScrollView to animate an Animated.View is not smooth

See original GitHub issue

Is this a bug report?

Yes

Environment

  1. react: 16.0.0-alpha.12,
  2. react-native -v: ^0.47.0,
  3. node -v: v7.7.3
  4. npm -v: 4.1.2
  5. yarn --version: 0.21.3
  • Target Platform: iOS and Android

  • Development Operating System: macOS

  • Build tools: expo

Steps to Reproduce

  1. Created an animated component of FlatList.
  2. Used the onScroll function to update the animated value.
  3. Placed a view (Animated.View) as the header above the animated FlatList using position absolute.
  4. Interpolate the animated value to change the view (Animated.View) using transform properties.

Expected Behavior

I saw this issue of how using scrollEventThrottle helps the smoothness. So I thought using FlatList would be smooth.

Actual Behavior

However, when scrolling the FlatList, the animated view does animate, but the animation is not smooth. 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 animated view (Header) animation is not smooth at all.

Reproducible Demo

Snack link for animated FlatList and animated header Animated Flat List

Update

So, I tried to implement the same functionality using ScrollView. However, I think, its even 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 @brentvatne . 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 on the device. But the same code doesn’t work smoothly when I copy paste the code and test it. So, I think the problem is with the react or react native version. I will update if I have any new update. Thank you.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
jevakalliocommented, Sep 3, 2017

I can reproduce this, seems like binding Animated.Views to ScrollView scroll position with Animated.event and useNativeDriver has gotten deoptimised on Android. It seems to mainly affect momentum scrolling, and is not noticeable while scrolling with finger held down.

Doing some bisecting on Snack, seems like this broke between Expo 18 (React Native 0.45) and Expo 19 (React Native 0.46).

Between those versions, seems like there were two commits landed to Animated, both by @janicduplessis:

Neither of them seems to be the obvious candidate.

The diff is https://github.com/facebook/react-native/compare/v0.45.1...v0.46.4#diff-f048d92ca0be679bc38d38147b311100

Additional steps to reproduce:

  1. Open this Snack on Android
  2. Swipe the screen up and down to show/hide the header bar
  3. Note that header bar animation is glitchy.
  4. Switch to Expo version 18 with the Snack version switcher
  5. Reopen Expo app, scan the QR code again
  6. Swipe the screen up and down to show/hide the header bar
  7. Note that header bar animation is no longer glitchy
5reactions
janicduplessiscommented, Sep 4, 2017

There has been a regression with scroll events on Android. https://github.com/facebook/react-native/commit/e964a7f4ef93fcadf5cfd1c269b77b13cb3be374 fixes it, I’ll try to get it cherry picked in the next 0.48 patch.

Read more comments on GitHub >

github_iconTop Results From Across the Web

react native - Using Animated.Flatlist and Animated.ScrollView ...
The animation works fine, but the animation is not smooth at all. I saw this issue of how using scrollEventThrottle helps the smoothness....
Read more >
React-native – Using Animated.Flatlist and ... - iTecNote
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...
Read more >
Animated and React Native ScrollViews | by evening kid
First, we import Animated and we need to create an animated value that will hold the translation value for the header. Just to...
Read more >
React Native Scroll Item animation effect - FlatList ... - YouTube
In this video tutorial we will create an amazing scrolling animation /effect that you can apply to the items from a FlatList, ScrollView, ......
Read more >
Animations - React Native
React Native provides two complementary animation systems: Animated for ... component types: View , Text , Image , ScrollView , FlatList and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found