From d0b33031b4783a2c4ae5503ce6135d9fef51051f Mon Sep 17 00:00:00 2001 From: Nathan Trost Date: Mon, 16 May 2016 09:30:36 -0500 Subject: [PATCH] Finalizing responsive header/ID --- .../components/griddle-responsive-header.js | 11 +++++----- src/app/pages/AppGriddle.js | 21 ------------------- 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/src/app/components/griddle-responsive-header.js b/src/app/components/griddle-responsive-header.js index 8505b7a..0a8c708 100644 --- a/src/app/components/griddle-responsive-header.js +++ b/src/app/components/griddle-responsive-header.js @@ -8,15 +8,16 @@ import GriddleCell from '../components/griddle-cell'; class GriddleResponsiveHeaders extends React.Component{ constructor(props){ super(props); + this.state ={ + responsiveView: false + }; - /* this.componentWillMount = this.componentWillMount.bind(this); this.componentDidMount = this.componentDidMount.bind(this); this.handleResize = this.handleResize.bind(this); - */ } - /* + componentWillMount() { window.addEventListener('load', this.handleResize); window.addEventListener('click', this.handleResize); @@ -31,7 +32,7 @@ class GriddleResponsiveHeaders extends React.Component{ const view = ( width < 992 ) ? true : false; this.setState({responsiveView: view}); } - */ + doMobileHeader(){ const columnInfo = this.props.rowData[this.props.metadata.columnName]; @@ -60,7 +61,7 @@ class GriddleResponsiveHeaders extends React.Component{ } render(){ - const responsiveView = this.props.rowData.responsiveView; + const responsiveView = this.state.responsiveView; if(responsiveView){ return this.doMobileHeader(); diff --git a/src/app/pages/AppGriddle.js b/src/app/pages/AppGriddle.js index a34a3fe..41a6dee 100644 --- a/src/app/pages/AppGriddle.js +++ b/src/app/pages/AppGriddle.js @@ -131,29 +131,8 @@ const columnMeta = [ class AppGriddle extends React.Component { constructor(props){ super(props); - this.state = { - responsiveView: false - }; - - this.componentWillMount = this.componentWillMount.bind(this); - this.componentDidMount = this.componentDidMount.bind(this); - this.handleResize = this.handleResize.bind(this); - } - - componentWillMount() { - window.addEventListener('load', this.handleResize); - window.addEventListener('click', this.handleResize); } - componentDidMount() { - window.addEventListener('resize', this.handleResize); - } - - handleResize(e) { - const width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; - const view = ( width < 992 ) ? true : false; - this.setState({responsiveView: view}); - } render() { return (