Этот коммит содержится в:
=Corey Hulen
2015-10-07 09:13:42 -07:00
родитель e83dd55361
Коммит 8a65601db4

Просмотреть файл

@@ -9,6 +9,7 @@ export default class ErrorBar extends React.Component {
this.onErrorChange = this.onErrorChange.bind(this); this.onErrorChange = this.onErrorChange.bind(this);
this.handleClose = this.handleClose.bind(this); this.handleClose = this.handleClose.bind(this);
this.resize = this.resize.bind(this);
this.prevTimer = null; this.prevTimer = null;
this.state = ErrorStore.getLastError(); this.state = ErrorStore.getLastError();
@@ -45,10 +46,7 @@ export default class ErrorBar extends React.Component {
return false; return false;
} }
componentDidMount() { resize() {
ErrorStore.addChangeListener(this.onErrorChange);
$(window).resize(() => {
if (this.isValidError(this.state)) { if (this.isValidError(this.state)) {
var height = $(React.findDOMNode(this)).outerHeight(); var height = $(React.findDOMNode(this)).outerHeight();
height = height < 30 ? 30 : height; height = height < 30 ? 30 : height;
@@ -56,21 +54,24 @@ export default class ErrorBar extends React.Component {
} else { } else {
$('body').css('padding-top', '0'); $('body').css('padding-top', '0');
} }
}
componentDidMount() {
ErrorStore.addChangeListener(this.onErrorChange);
$(window).resize(() => {
this.resize();
}); });
this.resize();
} }
componentWillUnmount() { componentWillUnmount() {
ErrorStore.removeChangeListener(this.onErrorChange); ErrorStore.removeChangeListener(this.onErrorChange);
} }
componentDidUpdate(nextProps, nextState) { componentDidUpdate() {
if (this.isValidError(nextState)) { this.resize();
var height = $(React.findDOMNode(this)).outerHeight();
height = height < 30 ? 30 : height;
$('body').css('padding-top', height + 'px');
} else {
$('body').css('padding-top', '0');
}
} }
onErrorChange() { onErrorChange() {