diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index b42dc736f218b4..266e7283603d23 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -233,6 +233,19 @@ const ScrollView = createReactClass({ * - `true`, deprecated, use 'always' instead */ keyboardShouldPersistTaps: PropTypes.oneOf(['always', 'never', 'handled', false, true]), + /** + * When non-null, the scroll view will adjust the scroll position so that the content at or + * beyond the specified index that is currently visible will not change position. This is useful + * for lists that are loading content in both directions, e.g. a chat thread, where new messages + * coming in might otherwise cause the scroll position to jump. A value of 1 can be used to skip + * a spinner that does not need to maintain position. The default value is null. + * + * Caveat: reordering elements in the scrollview with this enabled will probably cause jumpiness + * and jank. It can be fixed, but there are currently no plans to do so. + * + * @platform ios + */ + maintainPositionAtOrBeyondIndex: PropTypes.number, /** * The maximum allowed zoom scale. The default value is 1.0. * @platform ios diff --git a/RNTester/js/ScrollViewExample.js b/RNTester/js/ScrollViewExample.js index 0074ea91c2ad2b..2d0dcde3d88a31 100644 --- a/RNTester/js/ScrollViewExample.js +++ b/RNTester/js/ScrollViewExample.js @@ -12,10 +12,13 @@ */ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var { - Platform, +import type {StyleObj} from 'StyleSheetTypes'; + +const ActivityIndicator = require('ActivityIndicator'); +const Platform = require('Platform'); +const React = require('react'); +const ReactNative = require('react-native'); +const { ScrollView, StyleSheet, Text, @@ -30,11 +33,11 @@ exports.description = 'Component that enables scrolling through child components'; exports.examples = [ { - title: '', + title: '\n', description: 'To make content scrollable, wrap it within a component', render: function() { - var _scrollView: ScrollView; + let _scrollView: ScrollView; return ( {THUMB_URLS.map(createThumbRow)} - { _scrollView.scrollTo({y: 0}); - }}> - Scroll to top - - +