Web: Components: Added recommended bind`s for functions at GroupButtonsMenu component

This commit is contained in:
Ilya Oleshko 2019-07-25 14:00:03 +03:00
parent e359cc645f
commit 26f3c233bf

View File

@ -62,14 +62,18 @@ class GroupButtonsMenu extends React.PureComponent {
constructor(props) {
super(props);
this.updateMenu = this.updateMenu.bind(this);
this.state = {
priorityItems: props.menuItems,
moreItems: [],
visible: true
}
this.fullMenuArray = this.props.menuItems;
this.checkBox = this.props.checkBox;
this.updateMenu = this.updateMenu.bind(this);
this.howManyItemsInMenuArray = this.howManyItemsInMenuArray.bind(this);
}
componentDidMount() {
@ -85,7 +89,7 @@ class GroupButtonsMenu extends React.PureComponent {
}
};
howManyItemsInMenuArray(array, outerWidth, initialWidth, minimumNumberInNav) {
howManyItemsInMenuArray = (array, outerWidth, initialWidth, minimumNumberInNav) => {
let total = (initialWidth + 180);
for (let i = 0; i < array.length; i++) {
if (total + array[i] > outerWidth) {
@ -94,9 +98,9 @@ class GroupButtonsMenu extends React.PureComponent {
total += array[i];
}
}
}
};
updateMenu() {
updateMenu = () => {
this.outerWidth = document.getElementById("groupMenuOuter") ? document.getElementById("groupMenuOuter").getBoundingClientRect().width : 0;
this.moreMenu = document.getElementById("moreMenu") ? document.getElementById("moreMenu").getBoundingClientRect().width : 0;
@ -108,7 +112,7 @@ class GroupButtonsMenu extends React.PureComponent {
priorityItems: priorityItems,
moreItems: priorityItems.length !== navItemsCopy.length ? navItemsCopy.slice(arrayAmount, navItemsCopy.length) : []
});
}
};
componentWillUnmount() {
window.removeEventListener('resize', this.updateMenu());