File indexing completed on 2025-01-26 05:27:58
0001 import React , {useEffect, useState, useRef,useContext} from 'react' 0002 import MobileLeftSidePanel from './MobileLeftSidePanel'; 0003 0004 const MobileLeftMenu = (props) => { 0005 const [overlayClass, setOverlayClass] = useState(''); 0006 const toggleEl = useRef(null); 0007 useEffect(() => { 0008 0009 document.addEventListener('mousedown',handleClick, false); 0010 document.addEventListener('touchend', handleClick, false); 0011 return () => { 0012 0013 document.removeEventListener('mousedown',handleClick, false); 0014 document.removeEventListener('touchend',handleClick, false); 0015 }; 0016 },[overlayClass]) 0017 0018 0019 const handleClick = e =>{ 0020 let cls = ""; 0021 if (toggleEl.current.contains(e.target)){ 0022 0023 if (overlayClass === "open"){ 0024 if (e.target.id === "left-side-overlay" || e.target.id === "menu-toggle-item"){ 0025 cls = ""; 0026 } else { 0027 cls = "open"; 0028 } 0029 } else { 0030 cls = "open"; 0031 } 0032 } 0033 0034 setTimeout(function () { 0035 setOverlayClass(cls); 0036 }, 200); 0037 } 0038 0039 return ( 0040 <div ref={toggleEl} id="metaheader-left-mobile" className={overlayClass} style={{'position':'absolute'}}> 0041 <a className="menu-toggle" id="menu-toggle-item"></a> 0042 <div id="left-side-overlay"> 0043 <MobileLeftSidePanel /> 0044 </div> 0045 </div> 0046 ) 0047 } 0048 0049 export default MobileLeftMenu 0050