import { Icon} from 'antd'; import cloneDeep from 'lodash/cloneDeep' import './index.less' class LeftRightLayout extends React.Component { constructor(props) { super(props); this.state = { showLeft:props.defaultShowLeft || true, isHover:false, leftWidth:props.leftWidth || 250, treeWidth:props.treeWidth || 250 // showRight:false } } componentWillReceiveProps(nextProps){ if(this.props.showRight !== nextProps.showRight){ this.showright(nextProps.showRight); } } leftShowCo(e){ const {showLeft,leftWidth,treeWidth} = this.state; const { onLeftChange,leftCom} = this.props; if(showLeft){ jQuery(".three-side-left").animate({width:0},300,"linear",onLeftChange && onLeftChange(false)) }else{ jQuery(".three-side-left").animate({width:leftCom? leftWidth:treeWidth},300,"linear",onLeftChange && onLeftChange(true)) } this.setState({showLeft:!showLeft}); e.stopPropagation(); e.preventDefault(); e.nativeEvent.preventDefault(); } render() { const {showLeft,height,isHover,leftWidth,treeWidth} = this.state; const {children,leftCom,rightCom,showRight} = this.props; return (
{ leftCom &&
{leftCom}
}
{ leftCom &&
this.setState({isHover:true})} onMouseLeave={()=>this.setState({isHover:false})} style={{background: `url('/cloudstore/images/e9/leftTree-${showLeft ? "show" : "hide"}${isHover ? "-hover" : ""}.png') no-repeat -2px 0`}} >
}
{children}
) } } export default LeftRightLayout;