mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
rename and extend new maintain visible content position feature
Summary: Builds off of https://github.com/facebook/react-native/commit/cae7179c9459f12b1cb5e1a1d998a9dc45f927dc - Make the prop a dictionary for more configuration options - Rename `maintainPositionAtOrBeyondIndex` -> `maintainVisibleContentPosition` + `minIndexForVisible` - Add autoscroll threshold feature Given the async native of RN JS and background layout, there is no way to trigger the scrollTo from JS without risking a delay, so we add the feature in native code. == Test Plan == ScrollViewExample: https://youtu.be/pmY8pxC9PRs Reviewed By: shergin Differential Revision: D6729160 fbshipit-source-id: 70f9bae460ce84567857a4f696da78ce9b3b834c
This commit is contained in:
committed by
Facebook Github Bot
parent
7e7d00aebe
commit
65184ec6b0
@@ -131,7 +131,7 @@ if (Platform.OS === 'ios') {
|
||||
exports.examples.push({
|
||||
title: '<ScrollView> smooth bi-directional content loading\n',
|
||||
description:
|
||||
'The `maintainPositionAtOrBeyondIndex` prop allows insertions to either end of the content ' +
|
||||
'The `maintainVisibleContentPosition` prop allows insertions to either end of the content ' +
|
||||
'without causing the visible content to jump. Re-ordering is not supported.',
|
||||
render: function() {
|
||||
let itemCount = 6;
|
||||
@@ -146,7 +146,10 @@ if (Platform.OS === 'ios') {
|
||||
<View>
|
||||
<ScrollView
|
||||
automaticallyAdjustContentInsets={false}
|
||||
maintainPositionAtOrBeyondIndex={1}
|
||||
maintainVisibleContentPosition={{
|
||||
minIndexForVisible: 1,
|
||||
autoscrollToTopThreshold: 10,
|
||||
}}
|
||||
style={styles.scrollView}>
|
||||
<ActivityIndicator style={{height: 40}} />
|
||||
{this.state.items.map(item =>
|
||||
@@ -156,9 +159,12 @@ if (Platform.OS === 'ios') {
|
||||
<ScrollView
|
||||
horizontal={true}
|
||||
automaticallyAdjustContentInsets={false}
|
||||
maintainPositionAtOrBeyondIndex={1}
|
||||
maintainVisibleContentPosition={{
|
||||
minIndexForVisible: 1,
|
||||
autoscrollToTopThreshold: 10,
|
||||
}}
|
||||
style={[styles.scrollView, styles.horizontalScrollView]}>
|
||||
<ActivityIndicator style={{height: 40}} />
|
||||
<ActivityIndicator style={{width: 40}} />
|
||||
{this.state.items.map(item =>
|
||||
React.cloneElement(item, {key: item.props.msg, style: null}),
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user