mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
ed29ba13f9
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
58 lines
1.7 KiB
JavaScript
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>);
|