diff --git a/index.js b/index.js index 4cfd3aa0..86623ced 100644 --- a/index.js +++ b/index.js @@ -47,6 +47,13 @@ var target = event.currentTarget; var rect = target.getBoundingClientRect(); + // Allow Drag + if (typeof this.props.allowDrag === 'function') { + if (this.props.allowDrag(item, index) === false) { + return; + }; + } + this.setState({ held: false, moved: false @@ -253,6 +260,13 @@ var previousIndex = listElements.indexOf(this.state.dragged.target); var newIndex = listElements.indexOf(collision); + // Allow Drop + if (typeof this.props.allowDrop === 'function') { + if (this.props.allowDrop(this.state.list[previousIndex], this.state.list[newIndex], newIndex, this.state.list) === false) { + return; + }; + } + this.state.list.splice(newIndex, 0, this.state.list.splice(previousIndex, 1)[0]); this.setState({list: this.state.list}); }