Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ import SortableGrid from 'react-native-sortable-grid'
- ``` dragStartAnimation ``` **Object**

Custom animation to override the default wiggle. Must be an object containing a key ```transform```, which is an array of transformations. Read about [transforms](https://facebook.github.io/react-native/docs/transforms.html) and [animations](https://facebook.github.io/react-native/docs/animated.html) and [see the example](example/customAnimationExample.js#L47) to learn how to use this.

- ``` disabledBlocks ``` **Array**

List of block indices that cannot be sorted. They cannot be dragged or displaced by dragging another block.

## SortableGrid methods

Expand Down
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class SortableGrid extends Component {
this.dragStartAnimation = null

this.rows = null
this.disabledBlocks = []
this.dragPosition = null
this.activeBlockOffset = null
this.blockWidth = null
Expand Down Expand Up @@ -183,7 +184,7 @@ class SortableGrid extends Component {
closestDistance = distance
}
})
if (closest !== this.state.activeBlock) {
if (this.disabledBlocks.indexOf(closest) === -1 && closest !== this.state.activeBlock) {
Animated.timing(
this._getBlock(closest).currentPosition,
{
Expand Down Expand Up @@ -336,6 +337,9 @@ class SortableGrid extends Component {
}

activateDrag = (key) => () => {
if (this.disabledBlocks.indexOf(key) !== -1) {
return
}
this.panCapture = true
this.onDragStart( this.itemOrder[key] )
this.setState({ activeBlock: key })
Expand Down