[ScrollView] Use `onScroll` without event throttling
See original GitHub issueI want to use the onScroll
handler to setState
another component in relation to the ScrollView
’s contentOffset
changing its value.
But the throttling of onScroll
causes noticeable jumps. Sometimes the component that has setState
called on it will never even update until much later on.
Is there a better way to achieve what I want?
Issue Analytics
- State:
- Created 8 years ago
- Comments:23 (10 by maintainers)
Top Results From Across the Web
Quick Tip: How to Throttle Scroll Events - SitePoint
This technique helps with checking if we are at a specific part of the page. Given the size of the page, it takes...
Read more >Scroll event firing too many times. I only want it to fire a ...
This will fire the first scroll event immediately and then get you a scroll event ... You can use Throttling fonction calls: throttling-function-calls...
Read more >ScrollView - React Native
scrollEventThrottle. iOS. ... This controls how often the scroll event will be fired while scrolling (as a time interval in ms). A...
Read more >Element: scroll event - Web APIs | MDN
The setTimeout() method is used to throttle the event handler because scroll events can fire at a high rate. For additional examples that ......
Read more >Throttling Scroll Events in JavaScript - John Kavanagh
Care needs to be taken when using the onScroll event; it can trigger frequently, leading to greater client-side resource (CPU) usage, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@zoharlevin nope, ended up changing our design requirements because we couldn’t get the performance 😦
@aleclarson yes, the problem is still apparent in a bundled release build.
Unless I’m missing something, I think this example is an example where React Native is just not gonna cut it performance-wise. Will have to drop down to a native scroll view.
I think what you’re looking for is something like this:
You can then animate your view using the state values & interpolate. I do this for a pull to refresh animation inside my
renderHeader
function: