From 5c615276f182043c2a9ca514eacd251103fdb1a5 Mon Sep 17 00:00:00 2001 From: David Seipp Date: Wed, 24 Aug 2016 10:42:21 -0400 Subject: [PATCH 1/2] allows preventing drag/drop based on characteristics of the source/destination items --- index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/index.js b/index.js index b3d4813a..e9b09f38 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ +/* eslint-disable */ (function () { 'use strict'; @@ -40,6 +41,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 @@ -246,6 +254,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}); } From 830ca599eaa568d920583d086a97117e8c256164 Mon Sep 17 00:00:00 2001 From: David Seipp Date: Wed, 24 Aug 2016 12:16:27 -0400 Subject: [PATCH 2/2] remove eslint comment --- index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/index.js b/index.js index e9b09f38..d8bb7913 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,3 @@ -/* eslint-disable */ (function () { 'use strict';