Skip to content

Commit

Permalink
Move ScrollView's contentOffset to common props
Browse files Browse the repository at this point in the history
Summary:
ScrollView's contentOffset prop was assumed to be iOS only, but in reality it is supported on Android as well: https://fburl.com/code/nuxpjpth

Changelog:
[General] - Move ScrollView's contentOffset to common props

Reviewed By: yungsters

Differential Revision: D36219604

fbshipit-source-id: f41679fd2ce7971a30129e0d91ae9f32b9cf756e
  • Loading branch information
genkikondo authored and facebook-github-bot committed May 9, 2022
1 parent 24a1f5c commit 7c581f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
11 changes: 5 additions & 6 deletions Libraries/Components/ScrollView/ScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,6 @@ type IOSProps = $ReadOnly<{|
* @platform ios
*/
contentInset?: ?EdgeInsetsProp,
/**
* Used to manually set the starting scroll offset.
* The default value is `{x: 0, y: 0}`.
* @platform ios
*/
contentOffset?: ?PointProp,
/**
* When true, the scroll view bounces when it reaches the end of the
* content if the content is larger then the scroll view along the axis of
Expand Down Expand Up @@ -457,6 +451,11 @@ export type Props = $ReadOnly<{|
* ```
*/
contentContainerStyle?: ?ViewStyleProp,
/**
* Used to manually set the starting scroll offset.
* The default value is `{x: 0, y: 0}`.
*/
contentOffset?: ?PointProp,
/**
* When true, the scroll view stops on the next index (in relation to scroll
* position at release) regardless of how fast the gesture is. This can be
Expand Down
14 changes: 7 additions & 7 deletions packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,13 @@ const examples = ([
return <SnapToOptions />;
},
},
{
title: '<ScrollView> (contentOffset = {x: 100, y: 0})\n',
description: 'Initial contentOffset can be set on ScrollView.',
render: function (): React.Node {
return <ContentOffsetList />;
},
},
]: Array<RNTesterModuleExample>);

if (Platform.OS === 'ios') {
Expand All @@ -411,13 +418,6 @@ if (Platform.OS === 'ios') {
return <CenterContentList />;
},
});
examples.push({
title: '<ScrollView> (contentOffset = {x: 100, y: 0})\n',
description: 'Initial contentOffset can be set on ScrollView.',
render: function (): React.Node {
return <ContentOffsetList />;
},
});
examples.push({
title: '<ScrollView> Always Bounces\n',
description: 'Always bounce vertically or horizontally.',
Expand Down

0 comments on commit 7c581f3

Please sign in to comment.