Merge pull request #1768 from merraysy/dev

Fix arrows updating issue when children change
old
Rubén Moya 2018-01-24 16:37:21 +01:00 committed by GitHub
commit e87ffb9df7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 6 deletions

View File

@ -59,6 +59,8 @@ const factory = (Tab, TabContent, FontIcon) => {
if (index !== prevIndex || children !== prevChildren) {
this.updatePointer(index);
}
this.updateArrows();
}
componentWillUnmount() {
@ -105,13 +107,18 @@ const factory = (Tab, TabContent, FontIcon) => {
const scrollLeft = this.navigationNode.scrollLeft;
const nav = this.navigationNode.getBoundingClientRect();
const lastLabel = this.navigationNode.children[idx].getBoundingClientRect();
const left = scrollLeft > 0;
const right = nav.right < (lastLabel.right - 5);
const { left: prevLeft, right: prevRight } = this.state.arrows;
this.setState({
arrows: {
left: scrollLeft > 0,
right: nav.right < (lastLabel.right - 5),
},
});
if (left !== prevLeft || right !== prevRight) {
this.setState({
arrows: {
left,
right,
},
});
}
}
}