Files
react-native/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js
T
Joshua Gross ed29ba13f9 Support contentOffset property in Android's ScrollView and HorizontalScrollView
Summary:
For a very long time, iOS has supported the `contentOffset` property but Android has not:

https://github.com/facebook/react-native/issues/6849

This property can be used, primarily, to autoscroll the ScrollView to a starting position when it is first rendered, to avoid "jumps" that occur by asynchronously scrolling to a start position.

Changelog: [Android][Changed] ScrollView now supports `contentOffset`

Reviewed By: mdvacca

Differential Revision: D21198236

fbshipit-source-id: 2b0773569ba42120cb1fcf0f3847ca98af2285e7
2020-04-23 15:39:45 -07:00

58 lines
1.7 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
*/
'use strict';
const registerGeneratedViewConfig = require('../../Utilities/registerGeneratedViewConfig');
const requireNativeComponent = require('../../ReactNative/requireNativeComponent');
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import type {ScrollViewNativeProps} from './ScrollViewNativeComponentType';
const AndroidHorizontalScrollViewViewConfig = {
uiViewClassName: 'AndroidHorizontalScrollView',
bubblingEventTypes: {},
directEventTypes: {},
validAttributes: {
decelerationRate: true,
disableIntervalMomentum: true,
endFillColor: {process: require('../../StyleSheet/processColor')},
fadingEdgeLength: true,
nestedScrollEnabled: true,
overScrollMode: true,
pagingEnabled: true,
persistentScrollbar: true,
scrollEnabled: true,
scrollPerfTag: true,
sendMomentumEvents: true,
showsHorizontalScrollIndicator: true,
snapToEnd: true,
snapToInterval: true,
snapToStart: true,
snapToOffsets: true,
contentOffset: true,
},
};
let AndroidHorizontalScrollViewNativeComponent;
if (global.RN$Bridgeless) {
registerGeneratedViewConfig(
'AndroidHorizontalScrollView',
AndroidHorizontalScrollViewViewConfig,
);
AndroidHorizontalScrollViewNativeComponent = 'AndroidHorizontalScrollView';
} else {
AndroidHorizontalScrollViewNativeComponent = requireNativeComponent<ScrollViewNativeProps>(
'AndroidHorizontalScrollView',
);
}
export default ((AndroidHorizontalScrollViewNativeComponent: any): HostComponent<ScrollViewNativeProps>);