Skip to content

Commit 00b1b09

Browse files
committed
Merge pull request ptomasroos#68 from oblador/initialPage
Add initialPage prop
2 parents 11cff26 + bdfd04e commit 00b1b09

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ module.exports = CustomTabBar;
151151
- **`springTension`** _(Integer)_ - a number between `1` and `100`, controls the amount of tension on the spring that guides the scroll animation - see [example](http://facebook.github.io/rebound-js/examples/#graph-canvas).
152152
- **`springFriction`** _(Integer)_ - a number between `1` and `30`, controls the amount of friction on the spring that guides the scroll animation - see [example](http://facebook.github.io/rebound-js/examples/#graph-canvas).
153153
- **`clampSpring`** _(Bool)_ - if `true`, the spring will not bounce at all - if `false`, it will oscillate around the target value before settling.
154+
- **`initialPage`** _(Integer)_ - the index of the initially selected tab, defaults to 0 === first tab.
154155
- **`children`** _(ReactComponents)_ - each top-level child component should have a `tabLabel` prop that can be used by the tab bar component to render out the labels. The default tab bar expects it to be a string, but you can use anything you want if you make a custom tab bar.
155156
156157
---

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ var ScrollableTabView = React.createClass({
2424
},
2525

2626
getInitialState() {
27-
return { currentPage: 0, scrollValue: new Animated.Value(0) };
27+
var currentPage = this.props.initialPage || 0;
28+
return { currentPage: currentPage, scrollValue: new Animated.Value(currentPage) };
2829
},
2930

3031
componentWillMount() {

0 commit comments

Comments
 (0)