Skip to content

Commit 03d61e1

Browse files
authored
Merge pull request ptomasroos#324 from jnuine/fix-tabBar-initial-page-rendering
Fix tabBar rendering when initialPage is last page
2 parents b45303c + 4ef8dda commit 03d61e1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ScrollableTabBar.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,21 @@ const ScrollableTabBar = React.createClass({
6161
const position = Math.floor(offset.value);
6262
const pageOffset = offset.value % 1;
6363
const tabCount = this.props.tabs.length;
64+
const lastTabPosition = tabCount - 1;
6465

65-
if (tabCount === 0 || offset.value < 0 || offset.value > tabCount - 1) {
66+
if (tabCount === 0 || offset.value < 0 || offset.value > lastTabPosition) {
6667
return;
6768
}
6869

69-
if (this.necessarilyMeasurementsCompleted(position)) {
70+
if (this.necessarilyMeasurementsCompleted(position, position === lastTabPosition)) {
7071
this.updateTabPanel(position, pageOffset);
7172
this.updateTabUnderline(position, pageOffset, tabCount);
7273
}
7374
},
7475

75-
necessarilyMeasurementsCompleted(position) {
76+
necessarilyMeasurementsCompleted(position, isLastTab) {
7677
return this._tabsMeasurements[position] &&
77-
this._tabsMeasurements[position + 1] &&
78+
(isLastTab || this._tabsMeasurements[position + 1]) &&
7879
this._tabContainerMeasurements &&
7980
this._containerMeasurements;
8081
},

0 commit comments

Comments
 (0)