only create resizer in MainSplit when ref becomes available
This commit is contained in:
parent
a40f1933f2
commit
d535f60bf6
1 changed files with 26 additions and 12 deletions
|
@ -35,28 +35,42 @@ export default class MainSplit extends React.Component {
|
||||||
this.resizeContainer,
|
this.resizeContainer,
|
||||||
FixedDistributor);
|
FixedDistributor);
|
||||||
resizer.setClassNames(classNames);
|
resizer.setClassNames(classNames);
|
||||||
return resizer;
|
const rhsSize = window.localStorage.getItem("mx_rhs_size");
|
||||||
|
if (rhsSize !== null) {
|
||||||
|
resizer.forHandleAt(0).resize(parseInt(rhsSize, 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
resizer.attach();
|
||||||
|
this.resizer = resizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
_setResizeContainerRef(div) {
|
_setResizeContainerRef(div) {
|
||||||
this.resizeContainer = div;
|
this.resizeContainer = div;
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadResizerPreferences() {
|
|
||||||
const rhsSize = window.localStorage.getItem("mx_rhs_size");
|
|
||||||
if (rhsSize !== null) {
|
|
||||||
this.resizer.forHandleAt(0).resize(parseInt(rhsSize, 10));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.resizer = this._createResizer();
|
if (this.props.panel && !this.collapsedRhs) {
|
||||||
this.resizer.attach();
|
this._createResizer();
|
||||||
this._loadResizerPreferences();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.resizer.detach();
|
this.resizer.detach();
|
||||||
|
this.resizer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps) {
|
||||||
|
const wasExpanded = !this.props.collapsedRhs && prevProps.collapsedRhs;
|
||||||
|
const wasCollapsed = this.props.collapsedRhs && !prevProps.collapsedRhs;
|
||||||
|
const wasPanelSet = this.props.panel && !prevProps.panel;
|
||||||
|
const wasPanelCleared = !this.props.panel && prevProps.panel;
|
||||||
|
|
||||||
|
if (wasExpanded || wasPanelSet) {
|
||||||
|
this._createResizer();
|
||||||
|
} else if (wasCollapsed || wasPanelCleared) {
|
||||||
|
this.resizer.detach();
|
||||||
|
this.resizer = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -68,7 +82,7 @@ export default class MainSplit extends React.Component {
|
||||||
} else {
|
} else {
|
||||||
return <div className="mx_MainSplit" ref={this._setResizeContainerRef}>
|
return <div className="mx_MainSplit" ref={this._setResizeContainerRef}>
|
||||||
{ bodyView }
|
{ bodyView }
|
||||||
<ResizeHandle reverse={true}/>
|
<ResizeHandle reverse={true} />
|
||||||
{ panelView }
|
{ panelView }
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue