Skip to content

Commit

Permalink
Re-measure when layout change
Browse files Browse the repository at this point in the history
  • Loading branch information
Lap Shun Yu authored and drtangible committed May 18, 2016
1 parent 92dea8f commit eba5659
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions components/SectionList.js
Expand Up @@ -63,20 +63,25 @@ class SectionList extends Component {
}

componentDidMount() {
const sectionItem = this.refs.sectionItem0;

this.measureTimer = setTimeout(() => {
sectionItem.measure((x, y, width, height, pageX, pageY) => {
//console.log([x, y, width, height, pageX, pageY]);
this.measure = {
y: pageY,
height
};
})
}, 0);

this.onMeasure();
//console.log(sectionItem);
}

onMeasure() {
if (this && this.refs) {
const sectionItem = this.refs.sectionItem0;
this.measureTimer = setTimeout(() => {
sectionItem.measure((x, y, width, height, pageX, pageY) => {
//console.log([x, y, width, height, pageX, pageY]);
this.measure = {
y: pageY,
height
};
})
}, 0);
}
}

componentWillUnmount() {
this.measureTimer && clearTimeout(this.measureTimer);
}
Expand Down Expand Up @@ -127,6 +132,7 @@ class SectionList extends Component {
onResponderGrant={this.detectAndScrollToSection}
onResponderMove={this.detectAndScrollToSection}
onResponderRelease={this.resetSection}
onLayout={()=>{this.onMeasure()}}
>
{sections}
</View>
Expand Down

0 comments on commit eba5659

Please sign in to comment.