Pass resizer top & bottom pixels into children
parent
6fa3245cc3
commit
e8f7751c30
|
@ -34,6 +34,7 @@ class ResizeContainer extends Component {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.setState({
|
this.setState({
|
||||||
bottomHeightPixels: this.bottom.getBoundingClientRect().height,
|
bottomHeightPixels: this.bottom.getBoundingClientRect().height,
|
||||||
|
topHeightPixels: this.top.getBoundingClientRect().height,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,11 +93,18 @@ class ResizeContainer extends Component {
|
||||||
topHeight: `${newTopPanelPercent}%`,
|
topHeight: `${newTopPanelPercent}%`,
|
||||||
bottomHeight: `${newBottomPanelPercent}%`,
|
bottomHeight: `${newBottomPanelPercent}%`,
|
||||||
bottomHeightPixels,
|
bottomHeightPixels,
|
||||||
|
topHeightPixels,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {bottomHeightPixels, topHeight, bottomHeight, isDragging} = this.state
|
const {
|
||||||
|
topHeightPixels,
|
||||||
|
bottomHeightPixels,
|
||||||
|
topHeight,
|
||||||
|
bottomHeight,
|
||||||
|
isDragging,
|
||||||
|
} = this.state
|
||||||
const {containerClass, children} = this.props
|
const {containerClass, children} = this.props
|
||||||
|
|
||||||
if (React.Children.count(children) > maximumNumChildren) {
|
if (React.Children.count(children) > maximumNumChildren) {
|
||||||
|
@ -116,9 +124,14 @@ class ResizeContainer extends Component {
|
||||||
onMouseMove={this.handleDrag}
|
onMouseMove={this.handleDrag}
|
||||||
ref={r => (this.resizeContainer = r)}
|
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], {
|
{React.cloneElement(children[0], {
|
||||||
resizerBottomHeight: bottomHeightPixels,
|
resizerBottomHeight: bottomHeightPixels,
|
||||||
|
resizeTopHeight: topHeightPixels,
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
<ResizeHandle
|
<ResizeHandle
|
||||||
|
@ -133,6 +146,7 @@ class ResizeContainer extends Component {
|
||||||
>
|
>
|
||||||
{React.cloneElement(children[1], {
|
{React.cloneElement(children[1], {
|
||||||
resizerBottomHeight: bottomHeightPixels,
|
resizerBottomHeight: bottomHeightPixels,
|
||||||
|
resizerTopHeight: topHeightPixels,
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue