Files
weave-scope/client/app/scripts/components/nodes.js
David Kaltschmidt 2ce5a39d45 Make node/edge highlighter objects immutable in app store
* refactor, no functionality changed
2016-03-16 11:29:40 +01:00

42 lines
888 B
JavaScript

import React from 'react';
import NodesChart from '../charts/nodes-chart';
const navbarHeight = 160;
const marginTop = 0;
export default class Nodes extends React.Component {
constructor(props, context) {
super(props, context);
this.handleResize = this.handleResize.bind(this);
this.state = {
width: window.innerWidth,
height: window.innerHeight - navbarHeight - marginTop
};
}
componentDidMount() {
window.addEventListener('resize', this.handleResize);
}
componentWillUnmount() {
window.removeEventListener('resize', this.handleResize);
}
render() {
return <NodesChart {...this.props} {...this.state} />;
}
handleResize() {
this.setDimensions();
}
setDimensions() {
const width = window.innerWidth;
const height = window.innerHeight - navbarHeight - marginTop;
this.setState({height, width});
}
}