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.

ScrollView vertical pagination not working

See original GitHub issue

Description

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:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Palisandcommented, Jul 3, 2017

@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 of

<ViewPagerAndroid style={{transform: [{rotate: "90deg"}]}}>
  <View style={{transform: [{rotate: "-90deg"}]}}>...</View>
  ...
</ViewPagerAndroid>

If 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:

const {width, height} = Dimensions.get("window");

<ViewPagerAndroid style={
  {
    top: 0, 
    bottom: 0, 
    left: 0, 
    right: width - height,  // important, otherwise your views will be cut!
    transform: [{rotate: "90deg"}]
  }
}>
  <View style={{width, height, transform: [{rotate: "-90deg"}]}}>...</View>
  ...
</ViewPagerAndroid>

Hope this helps.

0reactions
PimDeWittecommented, Apr 3, 2018
Read more comments on GitHub >

github_iconTop 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 >

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