Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
getBoundingClientRect fix
Browse files Browse the repository at this point in the history
  • Loading branch information
martinnov92 committed Dec 7, 2017
1 parent a98d924 commit c4d5007
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
19 changes: 17 additions & 2 deletions src/components/Splitters/HandleBar.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';

import { HandleBarProps } from './typings/index';

class HandleBar extends React.Component<HandleBarProps, {}> {
div: HTMLDivElement;

public static defaultProps: Partial<HandleBarProps> = {
allowResize: true
};

render() {
const { position, handleMouseDown, allowResize } = this.props;
let allowResizeClass = allowResize ? '' : 'resize-not-allowed';

const classNames = [
'handle-bar',
position,
!allowResize && 'resize-not-allowed',
].filter((cls) => cls).join(' ');

return (
<div
className={`handle-bar ${position} ${allowResizeClass}`}
className={classNames}
ref={(node: HTMLDivElement) => this.div = node}
onMouseDown={(e) => handleMouseDown(e)}
onTouchStart={(e) => handleMouseDown(e)}
>
<span className="handle-bar_drag" />
</div>
);
}

getDivInstance = () => {
return ReactDOM.findDOMNode(this.div);
}
}

export default HandleBar;
23 changes: 21 additions & 2 deletions src/components/Splitters/Pane.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';

import { PaneProps } from './typings/index';

class Pane extends React.Component<PaneProps, {}> {
div: HTMLDivElement;

render() {
const { hasDetailPane, id, style, position, className } = this.props;
const isDetailPane = hasDetailPane ? 'bottom-detail-pane' : '';

const classNames = [
'pane',
hasDetailPane && 'bottom-detail-pane',
position,
className
].filter((cls) => cls).join(' ');

return (
<div id={id} className={`pane ${position} ${isDetailPane} ${className || ''}`} style={style}>
<div
id={id}
ref={(node: HTMLDivElement) => this.div = node}
className={classNames}
style={style}>
{this.props.children}
</div>
);
}

getDivInstance = () => {
return ReactDOM.findDOMNode(this.div);
}
}

export default Pane;
4 changes: 2 additions & 2 deletions src/components/Splitters/Splitter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ export class Splitter extends React.Component<SplitterProps, SplitterState> {
let nodeWrapperSize;
let primaryPaneOffset;
let wrapper = ReactDOM.findDOMNode(this.paneWrapper).getBoundingClientRect();
let primaryPane = ReactDOM.findDOMNode(this.panePrimary).getBoundingClientRect();
let handleBarSize = ReactDOM.findDOMNode(this.handlebar).getBoundingClientRect();
let primaryPane = this.panePrimary.getDivInstance().getBoundingClientRect();
let handleBarSize = this.handlebar.getDivInstance().getBoundingClientRect();

const posInHandleBar = this.props.position === 'vertical'
? handleBarSize.left - cX
Expand Down

0 comments on commit c4d5007

Please sign in to comment.