Skip to content

Commit e63e6be

Browse files
committed
content offset for android
1 parent 703416f commit e63e6be

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

examples/FacebookTabsExample/ScrollableTabsExample.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default React.createClass({
1010
render() {
1111
return <ScrollableTabView
1212
style={{marginTop: 20, }}
13-
initialPage={0}
13+
initialPage={2}
1414
renderTabBar={() => <ScrollableTabBar />}
1515
>
1616
<Text tabLabel='Tab #1'>My</Text>

index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const {
1111
ScrollView,
1212
StyleSheet,
1313
InteractionManager,
14+
Platform,
1415
} = ReactNative;
1516
const TimerMixin = require('react-timer-mixin');
1617

@@ -63,6 +64,15 @@ const ScrollableTabView = React.createClass({
6364
};
6465
},
6566

67+
componentDidMount() {
68+
InteractionManager.runAfterInteractions(() => {
69+
if (this.scrollView && Platform.OS === 'android') {
70+
const x = this.props.initialPage * this.state.containerWidth;
71+
this.scrollView.scrollTo({ x, animated: false });
72+
}
73+
});
74+
},
75+
6676
componentWillReceiveProps(props) {
6777
if (props.children !== this.props.children) {
6878
this.updateSceneKeys({ page: this.state.currentPage, children: props.children, });

0 commit comments

Comments
 (0)