|
1 | 1 | # React Split Pane |
2 | 2 |
|
3 | | -Split-Pane component built with [React](http://facebook.github.io/react), can be split vertically or horizontally. |
4 | | - |
5 | | -``` |
6 | | -npm install react-split-pane |
7 | | -``` |
8 | | - |
| 3 | +[](https://www.npmjs.com/package/react-split-pane) |
| 4 | + |
| 5 | +[](https://npmcharts.com/compare/react-split-pane?minimal=true) |
| 6 | +[](https://npmcharts.com/compare/react-split-pane?minimal=true) |
9 | 7 | [](https://travis-ci.org/tomkp/react-split-pane) |
10 | 8 | [](https://coveralls.io/r/tomkp/react-split-pane) |
11 | 9 |
|
| 10 | +Split-Pane React component, can be nested or split vertically or horizontally. Check out some demos [here](http://react-split-pane.surge.sh/)! |
12 | 11 |
|
13 | | -Check out the [demos](http://react-split-pane.surge.sh/) |
| 12 | +## Installing |
| 13 | +```sh |
| 14 | +npm install react-split-pane |
| 15 | + |
| 16 | +# or if you use yarn |
14 | 17 |
|
| 18 | +yarn add react-split-pane |
| 19 | +``` |
15 | 20 |
|
| 21 | +## Example Usage |
16 | 22 | ```html |
17 | | - <SplitPane split="vertical" minSize={50} defaultSize={100}> |
18 | | - <div></div> |
19 | | - <div></div> |
20 | | - </SplitPane> |
| 23 | + <SplitPane split="vertical" minSize={50} defaultSize={100}> |
| 24 | + <div></div> |
| 25 | + <div></div> |
| 26 | + </SplitPane> |
21 | 27 | ``` |
22 | 28 |
|
23 | 29 | ```html |
24 | | - <SplitPane split="vertical" minSize={50}> |
25 | | - <div></div> |
26 | | - <SplitPane split="horizontal"> |
27 | | - <div></div> |
28 | | - <div></div> |
29 | | - </SplitPane> |
30 | | - </SplitPane> |
| 30 | + <SplitPane split="vertical" minSize={50}> |
| 31 | + <div></div> |
| 32 | + <SplitPane split="horizontal"> |
| 33 | + <div></div> |
| 34 | + <div></div> |
| 35 | + </SplitPane> |
| 36 | + </SplitPane> |
31 | 37 | ``` |
32 | 38 |
|
33 | | -### Primary pane |
| 39 | +## Props |
34 | 40 |
|
| 41 | +### primary |
35 | 42 | By dragging 'draggable' surface you can change size of the first pane. |
36 | 43 | The first pane keeps then its size while the second pane is resized by browser window. |
37 | 44 | By default it is the left pane for 'vertical' SplitPane and the top pane for 'horizontal' SplitPane. |
@@ -63,7 +70,25 @@ size of the 'resizable' pane in this case). This can be useful also in the full- |
63 | 70 | ### step |
64 | 71 | You can use the step prop to only allow resizing in fixed increments. |
65 | 72 |
|
66 | | -### Persisting Positions |
| 73 | +### onDragStarted |
| 74 | +This callback is invoked when a drag starts. |
| 75 | + |
| 76 | +### onDragFinished |
| 77 | +This callback is invoked when a drag ends. |
| 78 | + |
| 79 | +### onChange |
| 80 | +This callback is invoked with the current drag during a drag event. It is recommended that it is wrapped in a debounce function. |
| 81 | + |
| 82 | +### Inline Styles |
| 83 | + |
| 84 | +You can also pass inline styles to the components via props. These are: |
| 85 | + |
| 86 | + * `paneStyle` - Styling to be applied to both panes |
| 87 | + * `pane1Style` - Styling to be applied to the first pane, with precedence over `paneStyle` |
| 88 | + * `pane2Style` - Styling to be applied to the second pane, with precedence over `paneStyle` |
| 89 | + * `resizerStyle` - Styling to be applied to the resizer bar |
| 90 | + |
| 91 | +## Persisting Positions |
67 | 92 |
|
68 | 93 | Each SplitPane accepts an onChange function prop. Used in conjunction with |
69 | 94 | defaultSize and a persistence layer, you can ensure that your splitter choices |
@@ -96,12 +121,7 @@ https://github.com/mozilla/localForage although hooking it up will be slightly |
96 | 121 | more involved. You are likely to be admired by all for judiciously avoiding |
97 | 122 | use of localStorage. |
98 | 123 |
|
99 | | -### Resizing callbacks |
100 | | - |
101 | | -If you need more control over resizing, SplitPane can notify you about when resizing started |
102 | | -and when it ended through two callbacks: `onDragStarted` and `onDragFinished`. |
103 | | - |
104 | | -### Example styling |
| 124 | +## Example styling |
105 | 125 |
|
106 | 126 | This gives a single pixel wide divider, but with a 'grabbable' surface of 11 pixels. |
107 | 127 |
|
@@ -161,23 +181,13 @@ Thanks to ```background-clip: padding-box;``` for making transparent borders pos |
161 | 181 | } |
162 | 182 |
|
163 | 183 | ``` |
164 | | -### Inline Styles |
165 | 184 |
|
166 | | -You can also pass inline styles to the components via props. These are: |
167 | | - |
168 | | - * `paneStyle` - Styling to be applied to both panes |
169 | | - * `pane1Style` - Styling to be applied to the first pane, with precedence over `paneStyle` |
170 | | - * `pane2Style` - Styling to be applied to the second pane, with precedence over `paneStyle` |
171 | | - * `resizerStyle` - Styling to be applied to the resizer bar |
| 185 | +## Contributing |
172 | 186 |
|
173 | | - |
174 | | -### Contributing |
175 | | - |
176 | | -I'm always happy to receive Pull Requests for contributions of any kind. |
| 187 | +I'm always happy to receive Pull Requests for contributions of any kind. |
177 | 188 |
|
178 | 189 | Please include tests and/or update the examples if possible. |
179 | | - |
| 190 | + |
180 | 191 | **I'm working on an updated version of this library, and looking for help:** https://github.com/tomkp/react-split-pane/pull/240 |
181 | | - |
| 192 | + |
182 | 193 | Thanks, Tom |
183 | | - |
|
0 commit comments