Pass resizer top & bottom pixels into children

pull/10616/head
Alex P 2017-11-22 15:08:37 -08:00
parent 0797eb188a
commit 5de3e08d80
1 changed files with 16 additions and 2 deletions

View File

@ -34,6 +34,7 @@ class ResizeContainer extends Component {
componentDidMount() {
this.setState({
bottomHeightPixels: this.bottom.getBoundingClientRect().height,
topHeightPixels: this.top.getBoundingClientRect().height,
})
}
@ -92,11 +93,18 @@ class ResizeContainer extends Component {
topHeight: `${newTopPanelPercent}%`,
bottomHeight: `${newBottomPanelPercent}%`,
bottomHeightPixels,
topHeightPixels,
})
}
render() {
const {bottomHeightPixels, topHeight, bottomHeight, isDragging} = this.state
const {
topHeightPixels,
bottomHeightPixels,
topHeight,
bottomHeight,
isDragging,
} = this.state
const {containerClass, children} = this.props
if (React.Children.count(children) > maximumNumChildren) {
@ -116,9 +124,14 @@ class ResizeContainer extends Component {
onMouseMove={this.handleDrag}
ref={r => (this.resizeContainer = r)}
>
<div className="resize--top" style={{height: topHeight}}>
<div
className="resize--top"
style={{height: topHeight}}
ref={r => (this.top = r)}
>
{React.cloneElement(children[0], {
resizerBottomHeight: bottomHeightPixels,
resizeTopHeight: topHeightPixels,
})}
</div>
<ResizeHandle
@ -133,6 +146,7 @@ class ResizeContainer extends Component {
>
{React.cloneElement(children[1], {
resizerBottomHeight: bottomHeightPixels,
resizerTopHeight: topHeightPixels,
})}
</div>
</div>