|
@@ -30,11 +30,11 @@ const CustomNavigation = (props) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- // const navTabs = document.querySelectorAll('ul.grw-custom-navbar > li.grw-custom-navtab');
|
|
|
|
|
|
|
+ const navTabs = document.querySelectorAll('ul.grw-custom-navbar > li.grw-custom-navtab');
|
|
|
|
|
+ const navBar = document.getElementById('grw-custom-navbar');
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
- const navBar = document.getElementById('grw-custom-navbar');
|
|
|
|
|
|
|
|
|
|
console.log(`useEffecet ${activeTab}`);
|
|
console.log(`useEffecet ${activeTab}`);
|
|
|
console.log('reffff', refs);
|
|
console.log('reffff', refs);
|
|
@@ -47,28 +47,28 @@ const CustomNavigation = (props) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- // if (navBar == null || navTabs == null) {
|
|
|
|
|
- // console.log(`${navBar},${navTabs}`);
|
|
|
|
|
- // setSliderWidth(5);
|
|
|
|
|
- // return;
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ if (navBar == null || navTabs == null) {
|
|
|
|
|
+ console.log(`${navBar},${navTabs}`);
|
|
|
|
|
+ setSliderWidth(5);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
- // const tempML = 0;
|
|
|
|
|
|
|
+ let tempML = 0;
|
|
|
|
|
|
|
|
- // const styles = [].map.call(navTabs, (el) => {
|
|
|
|
|
- // const width = getPercentage(el.offsetWidth, navBar.offsetWidth);
|
|
|
|
|
- // const marginLeft = tempML;
|
|
|
|
|
- // tempML += width;
|
|
|
|
|
- // return { width, marginLeft };
|
|
|
|
|
- // });
|
|
|
|
|
- // const { width, marginLeft } = styles[props.navTabMapping[activeTab].index];
|
|
|
|
|
|
|
+ const styles = [].map.call(navTabs, (el) => {
|
|
|
|
|
+ const width = getPercentage(el.offsetWidth, navBar.offsetWidth);
|
|
|
|
|
+ const marginLeft = tempML;
|
|
|
|
|
+ tempML += width;
|
|
|
|
|
+ return { width, marginLeft };
|
|
|
|
|
+ });
|
|
|
|
|
+ const { width, marginLeft } = styles[props.navTabMapping[activeTab].index];
|
|
|
|
|
|
|
|
- // setSliderWidth(width);
|
|
|
|
|
- // setSliderMarginLeft(marginLeft);
|
|
|
|
|
- // console.log(`sliderWidth = ${sliderWidth}`);
|
|
|
|
|
|
|
+ setSliderWidth(width);
|
|
|
|
|
+ setSliderMarginLeft(marginLeft);
|
|
|
|
|
+ console.log(`sliderWidth = ${sliderWidth}`);
|
|
|
|
|
|
|
|
- }, []);
|
|
|
|
|
|
|
+ }, [activeTab]);
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<React.Fragment>
|
|
<React.Fragment>
|