How can I disable bounce effect in Scrollview (React Native)?
Asked Answered
M

4

16

I have used Scrollview in my screen and when I log y offset I get negative values?

How can I disable Scrollview bouncing?

Mulry answered 27/11, 2019 at 14:5 Comment(0)
C
27

This code should worked:

<ScrollView
    alwaysBounceHorizontal={false}
    alwaysBounceVertical={false}
    bounces={false}
/>
Conformance answered 26/8, 2020 at 3:18 Comment(2)
Accordingly oficial react native documentation this properties use for just IOS, but how about Android? Any ideas how to disable bounce there?Ontogeny
@jocoders, check if this helps - https://mcmap.net/q/714412/-how-can-i-disable-bounce-effect-in-scrollview-react-nativeIncumbency
C
11

set this:

<ScrollView bounces={false}>
  ...
</ScrollView>
Charie answered 16/1, 2021 at 22:49 Comment(0)
I
9

The answers given by others only solve the issue for iOS, but for Android, the issue still persists.

Here is the final solution I found after some digging.

Solution for iOS: (https://reactnative.dev/docs/scrollview#bounces-ios)

<ScrollView
    alwaysBounceHorizontal={false}
    alwaysBounceVertical={false}
    bounces={false}
/>

Solution for Android: (https://reactnative.dev/docs/scrollview#overscrollmode-android)

<ScrollView
    overScrollMode="never"
/>
Incumbency answered 27/4, 2023 at 19:0 Comment(0)
G
1

There are props called alwaysBounceVertical. Set it to false.

<ScrollView
    alwaysBounceVertical={false}
/>

Here is doc.

Grados answered 27/11, 2019 at 14:10 Comment(4)
Yes. It work with ios. Can you please post your code that you have done ?Grados
<ScrollView style={styles.content} scrollEventThrottle={16} alwaysBounceVertical={false} onScroll={Animated.event( [{ nativeEvent: { contentOffset: { y: this.scrollYAnimatedValue } } }], { listener: (event) => this._handleScroll(event) } )}>Mulry
After adding this alwaysBounceVertical={false}, scrollview still bouncing ?Grados
So, may be this problem is by your onScroll . It should be onScroll={() => { // your code }}Grados

© 2022 - 2024 — McMap. All rights reserved.