Skip to content

Commit

Permalink
Add onlayout
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlevy0 authored Jan 8, 2020
1 parent 67eea6c commit b1a6078
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/SortableList.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ export default class SortableList extends Component {
enabled: scrollEnabled, // fix for Android
});
}

return (
<View style={containerStyle} ref={this._onRefContainer}>
<ScrollView
Expand Down Expand Up @@ -325,7 +324,8 @@ export default class SortableList extends Component {
}

_onUpdateLayouts() {
Promise.all([this._headerLayout, this._footerLayout, ...Object.values(this._rowsLayouts)])
const l = Object.values(this._rowsLayouts);
Promise.all([this._headerLayout, this._footerLayout, ...l])
.then(([headerLayout, footerLayout, ...rowsLayouts]) => {
// Can get correct container’s layout only after rows’s layouts.
this._container.measure((x, y, width, height, pageX, pageY) => {
Expand All @@ -339,15 +339,22 @@ export default class SortableList extends Component {
contentWidth += layout.width;
});

this.setState({
const newState = {
containerLayout: {x, y, width, height, pageX, pageY},
rowsLayouts: rowsLayoutsByKey,
headerLayout,
footerLayout,
contentHeight,
contentWidth,
}, () => {
this.setState({animated: true});
};


this.setState(newState, () => {
this.setState({animated: true}, () => {
if (this.props.onLayout) {
this.props.onLayout();
}
});
});
});
});
Expand Down

0 comments on commit b1a6078

Please sign in to comment.