const React = require('react'); const createClass = require('create-react-class'); const _ = require('lodash'); const cx = require('classnames'); const SplitPane = createClass({ getDefaultProps : function() { return { storageKey : 'naturalcrit-pane-split', onDragFinish : function(){} //fires when dragging }; }, getInitialState : function() { return { size : null, isDragging : false }; }, componentDidMount : function() { const paneSize = window.localStorage.getItem(this.props.storageKey); if(paneSize){ this.setState({ size : paneSize }); } }, handleUp : function(){ if(this.state.isDragging){ this.props.onDragFinish(this.state.size); window.localStorage.setItem(this.props.storageKey, this.state.size); } this.setState({ isDragging: false }); }, handleDown : function(){ this.setState({ isDragging: true }); //this.unFocus() }, handleMove : function(e){ if(!this.state.isDragging) return; this.setState({ size : e.pageX }); }, /* unFocus : function() { if(document.selection){ document.selection.empty(); }else{ window.getSelection().removeAllRanges(); } }, */ renderDivider : function(){ return
; }, render : function(){ return
{this.props.children[0]} {this.renderDivider()} {this.props.children[1]}
; } }); const Pane = createClass({ getDefaultProps : function() { return { width : null }; }, render : function(){ let styles = {}; if(this.props.width){ styles = { flex : 'none', width : `${this.props.width}px` }; } return
{this.props.children}
; } }); module.exports = SplitPane;