Gathering detailed insights and metrics for react-split-pane
Gathering detailed insights and metrics for react-split-pane
Gathering detailed insights and metrics for react-split-pane
Gathering detailed insights and metrics for react-split-pane
npm install react-split-pane
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
3,227 Stars
673 Commits
409 Forks
35 Watching
48 Branches
49 Contributors
Updated on 24 Nov 2024
Minified
Minified + Gzipped
JavaScript (97.69%)
CSS (2.31%)
Cumulative downloads
Total Downloads
Last day
-18.2%
29,770
Compared to previous day
Last week
-0.7%
182,342
Compared to previous week
Last month
13.3%
751,771
Compared to previous month
Last year
-11.4%
8,451,908
Compared to previous year
43
Split-Pane React component, can be nested or split vertically or horizontally!
1npm install react-split-pane 2 3# or if you use yarn 4 5yarn add react-split-pane
1<SplitPane split="vertical" minSize={50} defaultSize={100}> 2 <div /> 3 <div /> 4</SplitPane>
1<SplitPane split="vertical" minSize={50}> 2 <div /> 3 <SplitPane split="horizontal"> 4 <div /> 5 <div /> 6 </SplitPane> 7</SplitPane>
By dragging 'draggable' surface you can change size of the first pane.
The first pane keeps then its size while the second pane is resized by browser window.
By default it is the left pane for 'vertical' SplitPane and the top pane for 'horizontal' SplitPane.
If you want to keep size of the second pane and let the first pane to shrink or grow by browser window dimensions,
set SplitPane prop primary
to second
. In case of 'horizontal' SplitPane the height of bottom pane remains the same.
Resizing can be disabled by passing the allowResize
prop as false
(allowResize={false}
). Resizing is enabled by default.
You can also set the size of the pane using the size
prop. Note that a size set through props ignores the defaultSize
and minSize
properties.
In this example right pane keeps its width 200px while user is resizing browser window.
1<SplitPane split="vertical" defaultSize={200} primary="second"> 2 <div /> 3 <div /> 4</SplitPane>
You can limit the maximal size of the 'fixed' pane using the maxSize parameter with a positive value (measured in pixels but state just a number). If you wrap the SplitPane into a container component (yes you can, just remember the container has to have the relative or absolute positioning), then you'll need to limit the movement of the splitter (resizer) at the end of the SplitPane (otherwise it can be dragged outside the SplitPane and you don't catch it never more). For this purpose use the maxSize parameter with value 0. When dragged the splitter/resizer will stop at the border of the SplitPane component and think this you'll be able to pick it again and drag it back then. And more: if you set the maxSize to negative value (e.g. -200), then the splitter stops 200px before the border (in other words it sets the minimal size of the 'resizable' pane in this case). This can be useful also in the full-screen case of use.
You can use the step prop to only allow resizing in fixed increments.
This callback is invoked when a drag starts.
This callback is invoked when a drag ends.
This callback is invoked with the current drag during a drag event. It is recommended that it is wrapped in a debounce function.
You can also pass inline styles to the components via props. These are:
style
- Styling to be applied to the main container.paneStyle
- Styling to be applied to both panespane1Style
- Styling to be applied to the first pane, with precedence over paneStyle
pane2Style
- Styling to be applied to the second pane, with precedence over paneStyle
resizerStyle
- Styling to be applied to the resizer barEach SplitPane accepts an onChange function prop. Used in conjunction with defaultSize and a persistence layer, you can ensure that your splitter choices survive a refresh of your app.
For example, if you are comfortable with the trade-offs of localStorage, you could do something like the following:
1<SplitPane 2 split="vertical" 3 minSize={50} 4 defaultSize={parseInt(localStorage.getItem('splitPos'), 10)} 5 onChange={(size) => localStorage.setItem('splitPos', size)} 6> 7 <div /> 8 <div /> 9</SplitPane>
Disclaimer: localStorage has a variety of performance trade-offs. Browsers such as Firefox have now optimized localStorage use so that they will asynchronously initiate a read of all saved localStorage data for an origin once they know the page will load. If the data has not fully loaded by the time code accesses localStorage, the code will cause the page's main thread to block until the database load completes. When the main thread is blocked, no other JS code will run or layout will occur. In multiprocess browsers and for users with fast disk storage, this will be less of a problem. You are likely to get yelled at if you use localStorage.
A potentially better idea is to use something like https://github.com/mozilla/localForage although hooking it up will be slightly more involved. You are likely to be admired by all for judiciously avoiding use of localStorage.
This gives a single pixel wide divider, but with a 'grabbable' surface of 11 pixels.
Thanks to background-clip: padding-box;
for making transparent borders possible.
1.Resizer { 2 background: #000; 3 opacity: 0.2; 4 z-index: 1; 5 -moz-box-sizing: border-box; 6 -webkit-box-sizing: border-box; 7 box-sizing: border-box; 8 -moz-background-clip: padding; 9 -webkit-background-clip: padding; 10 background-clip: padding-box; 11} 12 13.Resizer:hover { 14 -webkit-transition: all 2s ease; 15 transition: all 2s ease; 16} 17 18.Resizer.horizontal { 19 height: 11px; 20 margin: -5px 0; 21 border-top: 5px solid rgba(255, 255, 255, 0); 22 border-bottom: 5px solid rgba(255, 255, 255, 0); 23 cursor: row-resize; 24 width: 100%; 25} 26 27.Resizer.horizontal:hover { 28 border-top: 5px solid rgba(0, 0, 0, 0.5); 29 border-bottom: 5px solid rgba(0, 0, 0, 0.5); 30} 31 32.Resizer.vertical { 33 width: 11px; 34 margin: 0 -5px; 35 border-left: 5px solid rgba(255, 255, 255, 0); 36 border-right: 5px solid rgba(255, 255, 255, 0); 37 cursor: col-resize; 38} 39 40.Resizer.vertical:hover { 41 border-left: 5px solid rgba(0, 0, 0, 0.5); 42 border-right: 5px solid rgba(0, 0, 0, 0.5); 43} 44.Resizer.disabled { 45 cursor: not-allowed; 46} 47.Resizer.disabled:hover { 48 border-color: transparent; 49}
I'm working on an updated version of this library, and looking for help:
Demo
http://react-split-pane-v2.surge.sh/
Install
1npm install react-split-pane@next 2 3# or if you use yarn 4 5yarn add react-split-pane@next
Usage
1import SplitPane, { Pane } from 'react-split-pane'; 2 3<SplitPane split="vertical"> 4 <Pane initialSize="200px">You can use a Pane component</Pane> 5 <div>or you can use a plain old div</div> 6 <Pane initialSize="25%" minSize="10%" maxSize="500px"> 7 Using a Pane allows you to specify any constraints directly 8 </Pane> 9</SplitPane>;
Pull request
https://github.com/tomkp/react-split-pane/pull/240
More discussion
https://github.com/tomkp/react-split-pane/issues/233
I'm always happy to receive Pull Requests for contributions of any kind.
Please include tests and/or update the examples if possible.
Thanks, Tom
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/9 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
118 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More