Sortable and resizable pane component for react.
See demo: http://bokuweb.github.io/react-sortable-pane
npm i react-sortable-pane
or
yarn add react-sortable-pane
import React from 'react';
import { SortablePane, Pane } from 'react-sortable-pane';
export default () => {
return (
<div>
<SortablePane
direction="horizontal"
margin={20}
>
<Pane id={0} key={0} width={120} height="100%">
<p>0</p>
</Pane>
<Pane id={1} key={1} width={120} height="100%">
<p>1</p>
</Pane>
</SortablePane>
</div>
);
};
The className
property is used to set the css classname
of a component.
The style
property is used to set the style of a component.
The direction
property is used to set the direction of a component.
If omitted the default direction is 'horizontal'
.
The margin
property is used to set the margin between Pane
component.
If omitted the default margin is 0
.
The zIndex
property is used to set the zIndex of a component.
If omitted the default margin is 100
.
The isSortable
property is used to control whether panes can be dragged or not.
If omitted, the default value is true
.
The disableEffect
property is used to disable floating effect.
If omitted the default margin is false
.
It is called when Pane
component order changed.
PaneProperty
definition is below.
type PaneProperty = $Exact<{
id: PaneId;
width: number | string;
height: number | string;
order: number;
}>
onResizeStart?: (e: SyntheticMouseEvent | SyntheticTouchEvent, id: PaneId, panes: PaneProperty[]) => void
It is called when Pane
component resize start.
onResize?: (e: SyntheticMouseEvent | SyntheticTouchEvent, id: PaneId, panes: PaneProperty[], data: PaneResizeData) => void
It is called when Pane
component resize.
PaneResizeData
definition is below.
type PaneResizeData = $Exact<{
pane: PaneProperty;
direction: $Values<typeof directionDict>; // 'x' | 'y' | 'xy'
delta: PaneSize; // { width: number; height: number }
}>
onResizeStop?: (e: SyntheticMouseEvent | SyntheticTouchEvent, id: PaneId, panes: PaneProperty[], data: PaneResizeData) => void
It is called when Pane
component resize stop.
PaneResizeData
definition is below.
type PaneResizeData = $Exact<{
pane: PaneProperty;
direction: $Values<typeof directionDict>; // 'x' | 'y' | 'xy'
delta: PaneSize; // { width: number; height: number }
}>
onDragStart?: (e: SyntheticMouseEvent | SyntheticTouchEvent, id: PaneId, panes: PaneProperty[]) => void
It is called when Pane
component dragging starts.
onDragStartStop?: (e: SyntheticMouseEvent | SyntheticTouchEvent, id: PaneId, panes: PaneProperty[]) => void
It is called when Pane
component dragging stop.
The id
property is used to Pane
component id.
The width
property is used to set the width of a Pane component.
For example, it can be 300, '300px', or 50%.
The height
property is used to set the width of a Pane component.
For example, it can be 300, '300px', or 50%.
The minWidth
property is used to set the minimum width of a Pane component.
The minHeight
property is used to set the minimum height of a Pane component.
The maxWidth
property is used to set the maximum width of a Pane component.
The maxHeight
property is used to set the maximum height of a Pane component.
The className
property is used to set the css classname of a Pane component.
The style
property is used to set the style of a Pane component.
The isResizable
property is used to set the resizable permission of a component.
The permission of x
, y
, xy
direction resizing.
If omitted the default value is { x: true, y: true, xy: true }
.
If you want to permit only x direction resizing, please set { x: true, y: false, xy: false }
.
- Update README.
- Fix Bug,
onResizeStart
andonResizeStop
not fired.
- Use flowtype
- Use rollup
- Change callback I/F
- Use
prop-types
package. - Fix #56 thanks @avaskys.
- Support server side rendering. #50 thanks @lazreg87
- Fix componentDidUpdate argument, use this.props instaead of prev.
- Use babel-preset-es2015-ie babel-preset-es2015-ie #47 thanks @PabloDiablo
- update readme
- Fixes a nasty bug
- Add isResizable props to Pane component
- Set
user-select: none
when resizeing or moving. - Add zIndex props.
- update example
- Fixes a nasty bug where all Panes could end up sharing the same static style #44 (thanks @ara4n)
- Add Object.assign transform plugin
- Add add-module-exports plugin
- Allow strings for width and height. (thanks @lanVS)
- Add onDragStart and onDragEnd props. (thanks @lanVS)
- Add
isSortable
props. (#34 thanks @lanVS)
- Change sort trigger position (#40 thanks @lanVS)
- Update react-motion(use "^0.4.3")
- Fix order update bug
- Fix size updater bug
- Fix size updater bug
- Fix order bug
- Update react-resizable-box(^1.2.0)
- Add order props to change order by parent component.
- Add husky and prepush hook.
- update packages to support react v15
- update pane size when props.width/height updated.
- Fix className bug.
- Update resizable box component.
- Support pane appen and remove.
- Support vertical mode.
- Fix pane size calculator.
- Add onOrderChange callback.
- Add disableEffect props.
- Fix eslint error.
- Add onResize callback.
publised.
The MIT License (MIT)
Copyright (c) 2017 @Bokuweb
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.