ScrollView vertical pagination not working
See original GitHub issueDescription
Added ScrollView to my component in this manner which works with pagination on android. But this I mean that as you swipe left or right the card gets centered to the screen on release.
<ScrollView
style={styles.container}
automaticallyAdjustInsets={false}
horizontal={true}
decelerationRate={0}
snapToInterval={CARD_WIDTH}
snapToAlignment="start"
contentContainerStyle={styles.content}
pagingEnabled={true}
>
<View style={styles.card}>
<Text>Card 1</Text>
</View>
<View style={styles.card}>
<Text>Card 2</Text>
</View>
<View style={styles.card}>
<Text>Card 3</Text>
</View>
<View style={styles.card}>
<Text>Card 4</Text>
</View>
</ScrollView>
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#F5FCFF',
},
content: {
alignItems: 'center',
},
card: {
flex: 1,
backgroundColor: '#ccc',
width: CARD_WIDTH,
height: CARD_WIDTH,
alignItems: 'center',
justifyContent: 'center',
}
}
Reproduction
But when changing horizontal={false}
in the ScrollView component, the view scroll up and down but the pagination no longer works.
Solution
Identify how to retain the pagination experience on vertical scroll.
Additional Information
- React Native version: 0.36.1
- Platform: android
- Operating System: MacOSX 10.10
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
UIScrollview with paging vertically working but user not ...
I am using the following code to scroll to the next page of a UITableView that has a scrollview. Scrolling works but the...
Read more >ScrollView With Paging in SwiftUI - Better Programming
'ScrollView with paging in SwiftUI' was the exact query I typed into Google when trying to implement horizontal scroll with paging in my...
Read more >ScrollView - React Native
When true, the scroll view stops on multiples of the scroll view's size when scrolling. This can be used for horizontal pagination.
Read more >How to cancel vertical scrolling on paging TabView in SwiftUI
Swipe down to dismiss # ... There's 1 caveat though, which is that this paging TabView also has vertical scrolling. This may not...
Read more >UIStackView not laying out as expected in a UIScrollView
I removed the constraints that tied the contentView's top and bottom to the scroll view. This made it work. But you told you...
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 FreeTop 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
Top GitHub Comments
@julesmoretti Following the first option of the accepted answer to this StackOverflow question allowed me to introduce vertical paging.
For iOS I just use
ScrollView
with snapping and for Android I’m doing something along the lines ofIf you are trying to use the vertical pager as an overlay (i.e. absolute positioning) you will have to supply a width and height to the pager’s children. Im my case, the overlay extends to the devices dimensions in portrait orientation:
Hope this helps.
Fixed this in https://github.com/facebook/react-native/pull/18679