Fix arrows updating issue when children change

old
Mohammed Erraysy 2017-11-29 10:38:14 +00:00
parent b381db4054
commit 3d42ef975f
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) { if (index !== prevIndex || children !== prevChildren) {
this.updatePointer(index); this.updatePointer(index);
} }
this.updateArrows();
} }
componentWillUnmount() { componentWillUnmount() {
@ -105,13 +107,18 @@ const factory = (Tab, TabContent, FontIcon) => {
const scrollLeft = this.navigationNode.scrollLeft; const scrollLeft = this.navigationNode.scrollLeft;
const nav = this.navigationNode.getBoundingClientRect(); const nav = this.navigationNode.getBoundingClientRect();
const lastLabel = this.navigationNode.children[idx].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({ if (left !== prevLeft || right !== prevRight) {
arrows: { this.setState({
left: scrollLeft > 0, arrows: {
right: nav.right < (lastLabel.right - 5), left,
}, right,
}); },
});
}
} }
} }