React Native - How to change scroll speed on onScroll event - react-native

I want ScrollView to scroll more fast because it take 1sec time to scroll end even if it scroll little distance.
Does ScrollView have a option of change scroll speed?
or Do I have a another way?

sorry, but the office doc does not support changing scroll speed of ScrollView component. if you need, you can try to write a new native scrollView.

Related

Scrolling to offset for SectionList in ReactNative

Is there a way to scroll based on offset rather than scrollToLocation for a Section List?
Currently, it only allows the scrolling to a specific section/index.
Also would there be a clever way to control the speed of the scrolling animation?

Animating during momentum scroll in react-native?

I'm attempting to create a custom NavBar on a screen that renders a ScrollView. Inside the NavBar, there's a button, that when pressed, causes the NavBar to translate downwards, thereby giving the appearance that the NavBar is expanding (This is done using Animated.spring() with the useNativeDriver option). Everything is working great, except if the ScrollView is still scrolling at the time the button is tapped (ie: when "momentum" scroll is taking place). In this scenario, the onPress handler that kicks off the NavBar animation is invoked as expected, but calls to Animated.spring() do not cause any animation to take place. Is it possible to either have the NavBar "expansion" animation to occur during the scroll, or pause the scroll to allow animation to proceed?
Like it's explained in RN docs the animation type you using are stoped by gesture events like scrolling, better use Animated.event() with onScrollprops combined with an interpolation animation to animate you footer.

React Native: ScrollView with auto scroll

I would like to create a carousel that scrolls automatically until the user scrolls / touches the ScrollView itself.
The auto-scrolling itself works fine with using scrollView.scrollTo but how could I detect if the user is interacting with the ScrollView? I took a look at the onScroll event but this does not seem to distinct between a user generated event and an event that was generated by calling scrollTo.
Also I'd like to know if it is possible to get the current scroll position from the ScrollView directly instead of reading it everytime from the onScroll event.
I'm very thankful for any tips and suggestions.
By digging into ScrollView's source code you can notice a few undocumented callbacks that will help you achieve what you're after, namely onTouchStart and onTouchEnd. These two callbacks are triggered only when user interacts with the ScrollView and not when you scroll programmatically.
You will probably want to clear your auto-scroll interval on onTouchStart and restart it after a delay on onTouchEnd.
Regarding your next question, the answer is no. As far as I know, no getter is currently exposed to retrieve the current scroll position. Therefore, you need to rely on the event passed to onScroll, retrieve event.nativeEvent.contentOffset['x' or 'y'], and store it in your component's state.
Note that if you're doing some heavy animations that need to follow scroll position closely (e.g. animated header or parallax image), it would be a good idea to use the native driver for Animated.event. You can learn more about it on React Native's blog.

ScrollView PullDown

I am trying to build a component to detect a pulldown on a scrollview. Pulldown being when you try to refresh facebook or twitter feeds.
So my approach was trying to use the onScroll method to detect the changes from scroll view.
onScroll={this.handleScroll}
handleScroll(event) {
console.log(event.nativeEvent.contentOffset.y);
}
However, what I found is when you are scrolling downward (like you are scrolling through a facebook or twitter feed), it will give you the value of the offset.
I then tried to emulate the 'pulldown' behavior where I would scroll in the opposite direction. The difficulty is when the scroll view reaches 0, I can't detect any decrease in scroll. Does that make sense? Basically how I can detect a pulldown when the scroll view is at 0.
You can use RefreshControl to achieve this

React Native: How to determine if component is in the view port

That's said there's a long ScrollView with lots of contents, and there's another component at the bottom of the page. I'm trying to lazy-rendering the bottom component when user scroll down enough. Is there any library has implemented this?
(I'm aware of ListView's onEndReached, but not quite sure if that helpful for this case.)
Appreciate if anyone could guide me a direction.
I create a simple lib for this:
https://github.com/chunghe/react-native-defer-renderer
basically you could get scroll position from the onScroll event of the ScrollView (e.nativeEvent.contentOffset), pass the scroll position to the child component. Then in the child component, you could get the distance from top from onLayout event (e.nativeEvent.layout.y).
That's pretty much all the tricks.
Put it at the end of the ScrollView?
ScrollViews do this by default:
removeClippedSubviews bool
Experimental: When true, offscreen child views (whose overflow value is hidden) are removed from their native backing superview when offscreen. This can improve scrolling performance on long lists. The default value is true.
https://facebook.github.io/react-native/docs/scrollview.html#removeclippedsubviews