Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
296 commits
Select commit Hold shift + click to select a range
3aaefc2
Semi
JakeSidSmith Oct 30, 2016
69473c9
Add reorder helper methods
JakeSidSmith Oct 30, 2016
b046422
Do not allow mutation
JakeSidSmith Oct 30, 2016
25bddfc
Prevent native scrolling always
JakeSidSmith Dec 10, 2016
4e447bf
Method to check if dragging
JakeSidSmith Dec 10, 2016
1c1d359
Remove commented out old code
JakeSidSmith Dec 10, 2016
c32c176
Remove commented old render code
JakeSidSmith Dec 10, 2016
3d658a7
Update example with retained state
JakeSidSmith Dec 10, 2016
6675fc3
Check if hold times are undefined
JakeSidSmith Dec 10, 2016
6e85ab3
Style input content
JakeSidSmith Dec 10, 2016
cfe1007
Root node ref
JakeSidSmith Dec 10, 2016
61539ed
Adjust scroll constants
JakeSidSmith Dec 10, 2016
e497802
Do not store mouse coords in state
JakeSidSmith Dec 10, 2016
23d823a
Store mouse offset on down & move
JakeSidSmith Dec 10, 2016
a235b4e
Setup auto scroll interval
JakeSidSmith Dec 10, 2016
bc5d081
Implement auto scrolling
JakeSidSmith Dec 10, 2016
8789266
Different scroll area for horizontal and vertical dragging
JakeSidSmith Dec 10, 2016
8b95e01
Missed horizontal checks
JakeSidSmith Dec 10, 2016
68bcdcf
Fix scrollMultiplier used outside scope
JakeSidSmith Dec 10, 2016
fb325fe
Fix linting
JakeSidSmith Dec 10, 2016
0704406
Update readme
JakeSidSmith Dec 10, 2016
7182b29
More readme updates
JakeSidSmith Dec 10, 2016
544a4b2
Change to alpha version
JakeSidSmith Dec 15, 2016
0cc5fee
Update node version
JakeSidSmith Dec 15, 2016
d00fedb
Set npm version
JakeSidSmith Dec 15, 2016
c8a7540
Add test dependencies
JakeSidSmith Dec 15, 2016
cc0097a
Add babel preset es2015 for example code
JakeSidSmith Dec 15, 2016
65522f9
Update gitignore
JakeSidSmith Dec 15, 2016
d6d1a47
Update example linting to use es6
JakeSidSmith Dec 15, 2016
aec9d65
Make examples more es6y
JakeSidSmith Dec 15, 2016
5d54234
ES6 class in examples
JakeSidSmith Dec 15, 2016
762ab4c
Update readme
JakeSidSmith Dec 15, 2016
1f09697
Adjust example import
JakeSidSmith Dec 15, 2016
82dbef1
Update readme
JakeSidSmith Dec 15, 2016
0c5fef6
Fix example linting
JakeSidSmith Dec 15, 2016
05d36af
Rename src folder (from lib)
JakeSidSmith Dec 15, 2016
1081a30
Setup tests
JakeSidSmith Dec 15, 2016
6b701e1
Fix examples
JakeSidSmith Dec 15, 2016
cdbe97e
Remove mention of shared props
JakeSidSmith Dec 15, 2016
92dac80
Update main in package.json
JakeSidSmith Dec 15, 2016
ecbc041
Add React peer dependency
JakeSidSmith Dec 15, 2016
589f2ff
Add enzyme dependency
JakeSidSmith Dec 15, 2016
819e14a
Update dependencies for enzyme
JakeSidSmith Dec 15, 2016
48a5185
Update readme
JakeSidSmith Dec 15, 2016
cf4e4bb
Add prop types & default props
JakeSidSmith Dec 15, 2016
90a5fa5
First 2 simple tests
JakeSidSmith Dec 15, 2016
7f69c51
Test name typo
JakeSidSmith Dec 15, 2016
9dd31b4
Describe basic rendering
JakeSidSmith Dec 15, 2016
e5e18f6
Test changing the component
JakeSidSmith Dec 15, 2016
5f53f39
Allow function as component
JakeSidSmith Dec 15, 2016
518eef6
Test functional component
JakeSidSmith Dec 15, 2016
41b9d3b
Test React class as component
JakeSidSmith Dec 15, 2016
6ae3701
Rename basic test file
JakeSidSmith Dec 15, 2016
34a45af
Istanbul ignore exports
JakeSidSmith Dec 15, 2016
43dd1e8
Add test for ref function
JakeSidSmith Dec 15, 2016
bc3f218
Update CircleCI node version
JakeSidSmith Dec 15, 2016
d8eb251
Begin creating custom mount utility
JakeSidSmith Dec 16, 2016
987a13c
Refactor mount util
JakeSidSmith Dec 16, 2016
4d88cfc
Add tag and forEach methods to mount util
JakeSidSmith Dec 16, 2016
2251129
Add methods to get name, props & state to mount util
JakeSidSmith Dec 16, 2016
25ae1ae
Rename mount util methods
JakeSidSmith Dec 16, 2016
c584343
Remove enzyme dependency
JakeSidSmith Dec 16, 2016
6cb6771
Fix tests
JakeSidSmith Dec 16, 2016
8bab8b2
Update mount util setProps & setState methods
JakeSidSmith Dec 16, 2016
6d3b817
Custom getRef prop (and update readme)
JakeSidSmith Dec 16, 2016
a35f9e0
Clone component & re-render to update props
JakeSidSmith Dec 16, 2016
14fcf42
Add unmount method to mount util
JakeSidSmith Dec 16, 2016
ebf6ccc
Add test for event listeners
JakeSidSmith Dec 16, 2016
910c1f3
More thorough event listener tests
JakeSidSmith Dec 16, 2016
cb8558c
Even more thorough event listener tests
JakeSidSmith Dec 16, 2016
78f830c
Test clearing timeouts & intervals on unmount
JakeSidSmith Dec 16, 2016
a0ca763
Return new mount instance on setProps
JakeSidSmith Dec 16, 2016
c28be21
Create test file for mount util
JakeSidSmith Dec 16, 2016
1ead6a7
Begin testing mount util
JakeSidSmith Dec 16, 2016
2843ba3
Test lifecycle methods
JakeSidSmith Dec 16, 2016
a825f4c
Test unmounting component
JakeSidSmith Dec 16, 2016
e0d6592
Test updating components props
JakeSidSmith Dec 16, 2016
deac107
Reset spies after test
JakeSidSmith Dec 16, 2016
3ff9b0f
Ensure component is not remounted
JakeSidSmith Dec 16, 2016
59a81a8
Include mount in test coverage
JakeSidSmith Dec 16, 2016
bfee84b
Update test component
JakeSidSmith Dec 16, 2016
697588a
Test tag name
JakeSidSmith Dec 16, 2016
2222a32
Test children and forEach
JakeSidSmith Dec 16, 2016
f670af1
Update tagName jquery plugin
JakeSidSmith Dec 16, 2016
c1ee533
Test getting components name
JakeSidSmith Dec 16, 2016
d623e9b
Further test component name
JakeSidSmith Dec 16, 2016
16641ca
Test getting and setting component state
JakeSidSmith Dec 16, 2016
cf15d06
Test triggering events
JakeSidSmith Dec 16, 2016
66c201b
Do not return wrappers from set props / state
JakeSidSmith Dec 16, 2016
0d72331
Test forEach without callback
JakeSidSmith Dec 16, 2016
a9b3a10
Use lodash assign instead of custom extend
JakeSidSmith Dec 17, 2016
5ffca32
No restriction on React version
JakeSidSmith Dec 17, 2016
dd5c761
Test module exports
JakeSidSmith Dec 17, 2016
b9af2ce
Break up basic tests
JakeSidSmith Dec 17, 2016
e5c4bb9
Test reorder function and small refactor
JakeSidSmith Dec 17, 2016
356800e
Test reorderImmutable and small refactor
JakeSidSmith Dec 17, 2016
51eb982
Always prevent default for context menus
JakeSidSmith Dec 17, 2016
775f4eb
Test isDragging
JakeSidSmith Dec 17, 2016
2405370
Test preventDefault
JakeSidSmith Dec 17, 2016
d2bf86f
Test preventNativeScrolling
JakeSidSmith Dec 17, 2016
3565694
Test persistEvent
JakeSidSmith Dec 17, 2016
902ba96
Test copyTouchKeys
JakeSidSmith Dec 17, 2016
7cef302
More specific call tests
JakeSidSmith Dec 17, 2016
2c63b7e
Test copyTouchKeys with no touches
JakeSidSmith Dec 18, 2016
e42edbd
Move expect
JakeSidSmith Dec 18, 2016
6db85ad
Tests for collision x and y
JakeSidSmith Dec 18, 2016
ba1a775
Create mock children
JakeSidSmith Dec 18, 2016
4079ad5
Move mock children into own describe
JakeSidSmith Dec 18, 2016
bfdfa38
Test findCollisionIndex with no lock
JakeSidSmith Dec 18, 2016
00087cb
Test storing reference to root node
JakeSidSmith Dec 18, 2016
1f4759c
Move methods & children stub into own files
JakeSidSmith Dec 18, 2016
ccb9d6b
Create horizontal children stub
JakeSidSmith Dec 18, 2016
8e53c0e
Test (& fix) horizontal children stub
JakeSidSmith Dec 18, 2016
4c9a2a9
Test collision horizontal and vertical
JakeSidSmith Dec 18, 2016
c5a6dbb
Test getHoldTime
JakeSidSmith Dec 18, 2016
c68410d
Update readme (more ES6)
JakeSidSmith Dec 18, 2016
2076049
autoScroll prop
JakeSidSmith Dec 18, 2016
11790e7
Abstract methods to return scroll offsets
JakeSidSmith Dec 18, 2016
b8cf63a
Disabled prop types & default
JakeSidSmith Dec 18, 2016
e0ce0ed
Begin testing scroll offsets
JakeSidSmith Dec 18, 2016
77064a8
Improve scroll offset test
JakeSidSmith Dec 18, 2016
4c764ff
More thorough tests for scroll offsets x & y
JakeSidSmith Dec 18, 2016
e02933c
Test half scroll speeds
JakeSidSmith Dec 18, 2016
b331651
Test autoScroll
JakeSidSmith Dec 18, 2016
cdce22f
Add placedIndex default state
JakeSidSmith Dec 18, 2016
4ee71af
Update readme
JakeSidSmith Dec 22, 2016
8309c03
Add multi-list example (for testing)
JakeSidSmith Feb 19, 2017
c12be33
Prevent passive listeners
JakeSidSmith Feb 19, 2017
c27a57a
Allow / disable content menus
JakeSidSmith Feb 19, 2017
8719350
Reorder Id & Group PropTypes
JakeSidSmith Feb 19, 2017
a19541e
Begin validating reorder Id and Group
JakeSidSmith Feb 19, 2017
3da2092
Update eslint config dep
JakeSidSmith Feb 19, 2017
4f66927
Remove equals from deps
JakeSidSmith Feb 19, 2017
8a96c50
Update lint scripts & config
JakeSidSmith Feb 19, 2017
542c17d
Fix linting errors in src
JakeSidSmith Feb 19, 2017
f2fc388
Some variables
JakeSidSmith Feb 20, 2017
81b281c
Create store & register listeners for single lists
JakeSidSmith Feb 20, 2017
449ce84
Missing semi
JakeSidSmith Feb 20, 2017
c432aa4
Fix typo in examples
JakeSidSmith Feb 20, 2017
7e4d4d2
Fix linting in tests
JakeSidSmith Feb 20, 2017
a81676f
Fix stop drag & group events
JakeSidSmith Feb 20, 2017
d294ddb
Remove log
JakeSidSmith Feb 20, 2017
4eb0fd9
Set placedId when beginning drag
JakeSidSmith Feb 20, 2017
b77c242
Update setDragState method & add activeGroup to state
JakeSidSmith Feb 20, 2017
c5cdd5d
Remove unused methods
JakeSidSmith Feb 20, 2017
5c6fdd2
Replace mutli-list examples callback
JakeSidSmith Feb 20, 2017
46747fe
Store draggedStyle
JakeSidSmith Feb 20, 2017
38be72b
Default store draggedStyle
JakeSidSmith Feb 20, 2017
8a94faf
Fix weird commit
JakeSidSmith Feb 20, 2017
7eadf0c
Store downPos in global state
JakeSidSmith Feb 20, 2017
128e400
Store mouseOffset in global scope
JakeSidSmith Feb 20, 2017
d5b5b07
Store mouseDownOffset in global scope
JakeSidSmith Feb 20, 2017
3990716
Add inputs to group example
JakeSidSmith Feb 22, 2017
fbfbed7
Store draggedElement & handle dragging & placing to different lists
JakeSidSmith Feb 22, 2017
b13fb3c
Remove unnecessary semis
JakeSidSmith Feb 22, 2017
fd59fe0
Allow placeholder in other lists
JakeSidSmith Feb 22, 2017
4c1248c
Reduce ifs
JakeSidSmith Feb 22, 2017
0baa8ab
Comments about store state
JakeSidSmith Feb 22, 2017
9cbce49
Clear store values on startDrag
JakeSidSmith Feb 22, 2017
12a0d68
Always allow setting placed index if involved
JakeSidSmith Feb 22, 2017
1d4ecf2
Reorder from to methods
JakeSidSmith Feb 22, 2017
c51e9ce
Call onReorder with IDs
JakeSidSmith Feb 22, 2017
ddabe52
Fix reorder multiple indices
JakeSidSmith Feb 22, 2017
1861000
Update examples to reorder multiple lists
JakeSidSmith Feb 22, 2017
944d302
Allow multi list to be dropped on empty list
JakeSidSmith Feb 22, 2017
afc5c01
Remove log from examples
JakeSidSmith Feb 22, 2017
40121dc
Allow dragging mutli list back to now empty list
JakeSidSmith Feb 22, 2017
011f60c
Fix linting
JakeSidSmith Feb 22, 2017
4b49849
Prevent dragging if moved
JakeSidSmith Feb 22, 2017
78543c7
Update multi list input styling & default value
JakeSidSmith Feb 22, 2017
47e208e
No need to create new Immutable Lists
JakeSidSmith Mar 12, 2017
25327ff
Update readme with new API
JakeSidSmith Mar 12, 2017
d21fa30
Improve example reordering
JakeSidSmith Mar 12, 2017
6692ea1
Update test setup
JakeSidSmith Mar 12, 2017
eeecda9
Add reorderIds and unmount in tests
JakeSidSmith Mar 12, 2017
0426eab
Context menu typo
JakeSidSmith Mar 12, 2017
8cc871e
Add info about disableContextMenu to readme
JakeSidSmith Mar 12, 2017
3866835
Update preventDefault tests
JakeSidSmith Mar 12, 2017
6aa5815
Update collision tests
JakeSidSmith Mar 12, 2017
9baa8bb
Fix scroll offset tests
JakeSidSmith Mar 12, 2017
075e8c7
Fix auto-scroll tests
JakeSidSmith Mar 12, 2017
bf45364
Test reorderFromTo helpers & fix array function
JakeSidSmith Mar 12, 2017
d8a14d5
Do not enforce coverage
JakeSidSmith Mar 12, 2017
e1658da
Add getRef prop type
JakeSidSmith Mar 12, 2017
452252d
Tidy up readme
JakeSidSmith Mar 12, 2017
dafcca1
Note about multi-list dragging
JakeSidSmith Mar 12, 2017
6dfeb00
Update readme
JakeSidSmith Mar 12, 2017
231cb78
Update deployer name
JakeSidSmith Mar 12, 2017
e8b42d6
Remove engines from package (yarn hates them)
JakeSidSmith Mar 12, 2017
c8b67e4
Add babel plugin istanbul to package
JakeSidSmith Mar 12, 2017
916d6dd
New alpha version
JakeSidSmith Apr 10, 2017
53da42b
Update node version
JakeSidSmith Aug 6, 2017
53e96ac
Install concurrently
JakeSidSmith Aug 6, 2017
4b767cb
Create start script
JakeSidSmith Aug 6, 2017
1a229b0
Update eslint configs
JakeSidSmith Aug 6, 2017
3aa1d3e
Update babel configs
JakeSidSmith Aug 6, 2017
fc4bb3f
Reorganize examples
JakeSidSmith Aug 6, 2017
fac6005
Begin creating kanban example
JakeSidSmith Aug 6, 2017
a82dffa
More ES6 syntax
JakeSidSmith Aug 6, 2017
0f93d98
To array kanban example
JakeSidSmith Aug 6, 2017
3f03101
Clearfix examples
JakeSidSmith Aug 6, 2017
f139247
Style kanban
JakeSidSmith Aug 6, 2017
855a5fe
Bold kanban header
JakeSidSmith Aug 6, 2017
1e5394b
Reorder single list items in kanban
JakeSidSmith Aug 6, 2017
f2a0d61
Remove padding bottom from lists
JakeSidSmith Aug 6, 2017
e624cc4
Delete lists
JakeSidSmith Aug 6, 2017
e9b6722
Fix unmount reorder group bug
JakeSidSmith Aug 6, 2017
2e1305c
Fix registering reorder group
JakeSidSmith Aug 6, 2017
4d50cc7
Add more lists to kanban
JakeSidSmith Aug 6, 2017
a009e58
Delete kanban items
JakeSidSmith Aug 6, 2017
b3ca233
Update kanban description
JakeSidSmith Aug 6, 2017
2fd0f2b
Move kanban example to top
JakeSidSmith Aug 6, 2017
7152430
Update alpha version
JakeSidSmith Aug 6, 2017
b90daf0
Merge remote-tracking branch 'origin/master' into rework
JakeSidSmith Aug 6, 2017
688fc72
Reduce height of kanban
JakeSidSmith Aug 6, 2017
81caa21
Test custom wrapper component
JakeSidSmith Aug 6, 2017
1c1dad3
Use findDOMNode if element is unavailable
JakeSidSmith Aug 6, 2017
3a9175d
Scroll target list
JakeSidSmith Aug 6, 2017
4d61f25
Update basic tests
JakeSidSmith Aug 6, 2017
2c37bfc
Xit some tests temporarily
JakeSidSmith Aug 6, 2017
31e911d
Do not drag to group if not in visible area
JakeSidSmith Aug 6, 2017
9fb0da1
Update demo protocol
JakeSidSmith Aug 13, 2017
1d82196
Auto scroll parents
JakeSidSmith Aug 13, 2017
d011ca7
Fix no javascript message in IE
JakeSidSmith Aug 13, 2017
3a90b84
Merge branch 'master' into rework
JakeSidSmith Nov 8, 2017
cb08fae
Test with lots of nested reorder components
JakeSidSmith Nov 28, 2017
25a91d5
Fix multiple reorder component lag
JakeSidSmith Nov 28, 2017
3704cfe
Put comments back
JakeSidSmith Nov 28, 2017
972013b
Increase alpha version
JakeSidSmith Nov 28, 2017
aad7952
Revert "Test with lots of nested reorder components"
JakeSidSmith Nov 28, 2017
50ba1e3
Use translate to offset elements
JakeSidSmith Nov 28, 2017
d72eccf
Increment alpha version
JakeSidSmith Nov 28, 2017
b02ce34
Mutate dragged styles
JakeSidSmith Dec 3, 2017
7ff6db1
Use create-react-class
JakeSidSmith Dec 15, 2017
d6d3a8d
Add prop-types dep
JakeSidSmith Dec 20, 2017
f1aea5e
Use prop-types from prop-types module
JakeSidSmith Dec 20, 2017
8a573b6
Update deps
JakeSidSmith Dec 20, 2017
c41ad93
Do not use refs
JakeSidSmith Dec 20, 2017
2c615b0
Fix tests
JakeSidSmith Dec 20, 2017
430868c
Remove lodash assign
JakeSidSmith Dec 20, 2017
2cd784a
Update eslint config
JakeSidSmith Dec 20, 2017
3414eb4
Increment alpha version
JakeSidSmith Dec 20, 2017
5476102
Update examples with click events
JakeSidSmith Dec 21, 2017
1d431b4
Fix typo in example
tmm1 Apr 6, 2018
b00e75e
Merge pull request #95 from tmm1/patch-1
JakeSidSmith Apr 8, 2018
75d7074
moved everything from componentwillmount to componentdidmount
Jun 6, 2018
9dbff98
Merge pull request #96 from mcculloughjchris/rework
JakeSidSmith Jun 6, 2018
e02f5a9
Update alpha version
JakeSidSmith Jun 6, 2018
ef898e7
Add 'overflow-anchor: none' to examples
JakeSidSmith Mar 16, 2021
281a9d6
Note about overflow anchor
JakeSidSmith Mar 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
"react"
],
"env": {
"mocha": {
"plugins": [
"istanbul"
]
}
}
}
6 changes: 6 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends":[
"jakesidsmith/base",
"jakesidsmith/browser"
]
}
4 changes: 4 additions & 0 deletions .mocharc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--require babel-core/register
--require tests/helpers/test-setup.js
--bail
--recursive
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.10.3
26 changes: 26 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"lines": 100,
"statements": 100,
"functions": 100,
"branches": 100,
"require": [],
"include": [
"src/**/*.js",
"tests/helpers/mount.js",
"tests/helpers/children-stub.js"
],
"exclude": [],
"extension": [
".js"
],
"reporter": [
"lcov",
"text-summary"
],
"cache": true,
"all": true,
"check-coverage": false,
"sourceMap": false,
"instrument": false,
"report-dir": "coverage"
}
268 changes: 108 additions & 160 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,188 +1,136 @@
# React Reorder (v2)
# React Reorder

__Drag & drop, touch enabled, reorder / sortable list, React component__

If you are using v3 alpha, please refer to [this documentation](https://github.com/JakeSidSmith/react-reorder/blob/rework/README.md).
[![CircleCI](https://circleci.com/gh/JakeSidSmith/react-reorder.svg?style=svg)](https://circleci.com/gh/JakeSidSmith/react-reorder)

If you are using v2, please refer to [this documentation](https://github.com/JakeSidSmith/react-reorder/blob/609de5a6be9ae7ea4b032b0b260b08bc524b362e/README.md).

## About

React Reorder is a React component that allows the user to drag-and-drop items in a list (horizontal / vertical) or a grid.
React Reorder is a React component that allows the user to drag-and-drop items in a list (horizontal / vertical), or a grid. You can also allow dragging items from one list to another.

It fully supports touch devices and auto-scrolls when a component is being dragged (check out the demo, link below).
It fully supports touch devices and auto-scrolls when a component is being dragged (check out the [demo](https://jakesidsmith.github.io/react-reorder/)).

It also allows the user to set a hold time (duration before drag begins) allowing additional events like clicking / tapping to be applied.

Although this project is very new, it has been thoroughly tested in all modern browsers (see supported browsers).

__[Demo](http://jakesidsmith.github.io/react-reorder/)__

## Installation

* Using npm
```
npm install react-reorder
```
Add `--save` or `-S` to update your package.json
Using npm

* Using bower
```
bower install react-reorder
```
Add `--save` or `-S` to update your bower.json
Add `--save` or `-S` to update your package.json

## Example

1. If using requirejs: add `react-reorder` to your `require.config`

```javascript
paths:
// <name> : <path/to/module>
'react-reorder': 'react-reorder/reorder'
}
```
```
npm install react-reorder
```

2. If using a module loader (requirejs / browserfiy / commonjs): require `react-reorder` where it will be used in your project

```javascript
var Reorder = require('react-reorder');
```

If using requirejs you'll probably want to wrap your module e.g.

```javascript
define(function (require) {
// Require react-reorder here
});
```

3. Configuration

**Note: If your array is an array of primitives (e.g. strings) then `itemKey` is not required as the string itself will be used as the key, however item keys must be unique in any case**

1. Using JSX

```javascript
<Reorder
// The key of each object in your list to use as the element key
itemKey='name'
// Lock horizontal to have a vertical list
lock='horizontal'
// The milliseconds to hold an item for before dragging begins
holdTime='500'
// The list to display
list={[
{name: 'Item 1'},
{name: 'Item 2'},
{name: 'Item 3'}
]}
// A template to display for each list item
template={ListItem}
// Function that is called once a reorder has been performed
callback={this.callback}
// Class to be applied to the outer list element
listClass='my-list'
// Class to be applied to each list item's wrapper element
itemClass='list-item'
// A function to be called if a list item is clicked (before hold time is up)
itemClicked={this.itemClicked}
// The item to be selected (adds 'selected' class)
selected={this.state.selected}
// The key to compare from the selected item object with each item object
selectedKey='uuid'
// Allows reordering to be disabled
disableReorder={false}/>
```

2. Using standard Javascript

```javascript
React.createElement(Reorder, {
// The key of each object in your list to use as the element key
itemKey: 'name',
// Lock horizontal to have a vertical list
lock: 'horizontal',
// The milliseconds to hold an item for before dragging begins
holdTime: '500',
// The list to display
list: [
{name: 'Item 1'},
{name: 'Item 2'},
{name: 'Item 3'}
],
// A template to display for each list item
template: ListItem,
// Function that is called once a reorder has been performed
callback: this.callback,
// Class to be applied to the outer list element
listClass: 'my-list',
// Class to be applied to each list item's wrapper element
itemClass: 'list-item',
// A function to be called if a list item is clicked (before hold time is up)
itemClicked: this.itemClicked,
// The item to be selected (adds 'selected' class)
selected: this.state.selected,
// The key to compare from the selected item object with each item object
selectedKey: 'uuid',
// Allows reordering to be disabled
disableReorder: false
})
```

5. Callback functions

1. The `callback` function that is called once a reorder has been performed

```javascript
function callback(event, itemThatHasBeenMoved, itemsPreviousIndex, itemsNewIndex, reorderedArray) {
// ...
}
```

2. The `itemClicked` function that is called when an item is clicked before any dragging begins

```javascript
function itemClicked(event, itemThatHasBeenClicked, itemsIndex) {
// ...
}
```

**Note: `event` will be the synthetic React event for either `mouseup` or `touchend`, and both contain `clientX` & `clientY` values (for ease of use)**

## Compatibility / Requirements
Using bower

* Version `2.x` tested and working with React `0.14`
Add `--save` or `-S` to update your bower.json

* Versions `1.x` tested and working with React `0.12` - `0.13`
```
bower install react-reorder
```

* requirejs / commonjs / browserify (__Optional, but recommended*__)

\* Has only been tested with requirejs & browserify

## Supported Browsers

### Desktop

* Internet Explorer 9+ (may support IE8**)

* Google Chrome (tested in version 39.0.2171.95(64-bit))

* Mozilla Firefox (tested in version 33.0)
## Example

* Opera (tested in version 26.0.1656.60)
If using a module loader (requirejs / browserfiy / commonjs): require `react-reorder` where it will be used in your project

```javascript
var Reorder = require('react-reorder');
var reorder = Reorder.reorder;
var reorderImmutable = Reorder.reorderImmutable;
var reorderFromTo = Reorder.reorderFromTo;
var reorderFromToImmutable = Reorder.reorderFromToImmutable;

// Or ES6

import Reorder, {
reorder,
reorderImmutable,
reorderFromTo,
reorderFromToImmutable
} from 'react-reorder';
```

### Configuration

```javascript
<Reorder
reorderId="my-list" // Unique ID that is used internally to track this list (required)
reorderGroup="reorder-group" // A group ID that allows items to be dragged between lists of the same group (optional)
getRef={this.storeRef.bind(this)} // Function that is passed a reference to the root node when mounted (optional)
component="ul" // Tag name or Component to be used for the wrapping element (optional), defaults to 'div'
placeholderClassName="placeholder" // Class name to be applied to placeholder elements (optional), defaults to 'placeholder'
draggedClassName="dragged" // Class name to be applied to dragged elements (optional), defaults to 'dragged'
lock="horizontal" // Lock the dragging direction (optional): vertical, horizontal (do not use with groups)
holdTime={500} // Default hold time before dragging begins (mouse & touch) (optional), defaults to 0
touchHoldTime={500} // Hold time before dragging begins on touch devices (optional), defaults to holdTime
mouseHoldTime={200} // Hold time before dragging begins with mouse (optional), defaults to holdTime
onReorder={this.onReorder.bind(this)} // Callback when an item is dropped (you will need this to update your state)
autoScroll={true} // Enable auto-scrolling when the pointer is close to the edge of the Reorder component (optional), defaults to true
disabled={false} // Disable reordering (optional), defaults to false
disableContextMenus={true} // Disable context menus when holding on touch devices (optional), defaults to true
placeholder={
<div className="custom-placeholder" /> // Custom placeholder element (optional), defaults to clone of dragged element
}
>
{
this.state.list.map((item) => (
<li key={item.name}>
{item.name}
</li>
)).toArray()
/*
Note this example is an ImmutableJS List so we must convert it to an array.
I've left this up to you to covert to an array, as react-reorder updates a lot,
and if I called this internally it could get rather slow,
whereas you have greater control over your component updates.
*/
}
</Reorder>
```

* Safari (tested in version 7.1.2 (9537.85.11.5))
### Callback functions

\** Have not had a chance to test in IE8, but IE8 is supported by React
The `onReorder` function that is called once a reorder has been performed.

You can use our helper functions for reordering your arrays.

### Mobile
```javascript
import { reorder, reorderImmutable, reorderFromTo, reorderFromToImmutable } from 'react-reorder';

* Chrome (tested in version 40.0.2214.89)
onReorder (event, previousIndex, nextIndex, fromId, toId) {
this.setState({
myList: reorder(this.state.myList, previousIndex, nextIndex);
});
}

onReorderGroup (event, previousIndex, nextIndex, fromId, toId) {
if (fromId === toId) {
const list = reorderImmutable(this.state[fromId], previousIndex, nextIndex);

this.setState({
[fromId]: list
});
} else {
const lists = reorderFromToImmutable({
from: this.state[fromId],
to: this.state[toId]
}, previousIndex, nextIndex);

this.setState({
[fromId]: lists.from,
[toId]: lists.to
});
}
}
```

* Safari (tested on iOS 8)
## Compatibility / Requirements

## Untested Browsers
* Version `3.x` tested and working with React `15`, but should be backward compatible at least a couple of versions.

* Internet Explorer 8*** (the lowest version that React supports)
## Weird Scrolling Behavior?

\*** If anyone could confirm that this works in IE8, that'd be awesome
It is recommended that you apply `overflow-anchor: none;` to any parent elements with overflow auto (including on either of just the x/y axis) to prevent unwanted auto-scrolling, or surprisingly fast auto-scrolling.
15 changes: 15 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
machine:
node:
version: 6.9.1

general:
branches:
ignore:
- gh-pages

deployment:
master:
branch: master
commands:
- npm run build
- scripts/deploy.sh
6 changes: 6 additions & 0 deletions examples/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"presets": [
"es2015",
"react"
]
}
8 changes: 8 additions & 0 deletions examples/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends":[
"jakesidsmith/commonjs",
"jakesidsmith/es6",
"jakesidsmith/react",
"jakesidsmith/browser"
]
}
Loading