From 26e8d03d04c07cba3ba8c269a9a0b6cdadaa847d Mon Sep 17 00:00:00 2001 From: eitanfrailich Date: Mon, 10 Jul 2017 10:17:51 +0300 Subject: [PATCH 1/3] add onDragStart prop --- README.md | 2 ++ index.js | 3 +++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 39b7d602..5a6cf367 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,8 @@ __[Demo](http://jakesidsmith.github.io/react-reorder/)__ selected={this.state.selected} // The key to compare from the selected item object with each item object selectedKey='uuid' + // Function that is called on when draging starts (after holding time) + onStartDrag={this.dragStart} // Allows reordering to be disabled disableReorder={false}/> ``` diff --git a/index.js b/index.js index 4cfd3aa0..31cb0dd6 100644 --- a/index.js +++ b/index.js @@ -31,6 +31,9 @@ }, startDrag: function (dragOffset, draggedStyle) { if (!this.props.disableReorder) { + if (typeof this.props.onStartDrag === 'function'){ + this.props.onStartDrag(dragOffset); + } this.setState({ dragOffset: dragOffset, draggedStyle: draggedStyle, From 63704a5a383ef4a8dfc9277a5fad7d385e9ca67e Mon Sep 17 00:00:00 2001 From: eitanfrailich Date: Mon, 10 Jul 2017 15:40:54 +0300 Subject: [PATCH 2/3] set passive: false --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 31cb0dd6..1b2844e7 100644 --- a/index.js +++ b/index.js @@ -31,7 +31,7 @@ }, startDrag: function (dragOffset, draggedStyle) { if (!this.props.disableReorder) { - if (typeof this.props.onStartDrag === 'function'){ + if (typeof this.props.onStartDrag === 'function') { this.props.onStartDrag(dragOffset); } this.setState({ @@ -117,9 +117,9 @@ window.addEventListener('mousemove', this.onMouseMove); // Mouse move // Touch events - window.addEventListener('touchend', this.onMouseUp); // Touch up - window.addEventListener('touchmove', this.onMouseMove); // Touch move - + window.addEventListener('touchend', this.onMouseUp, { passive: false }); // Touch up + window.addEventListener('touchmove', this.onMouseMove, { passive: false }); // Touch move + window.addEventListener('contextmenu', this.preventDefault); }, onMouseUp: function (event) { From d5e39bebc1dd91637327999ee2090b59e78fcd97 Mon Sep 17 00:00:00 2001 From: Jake Date: Tue, 11 Jul 2017 09:28:41 +0100 Subject: [PATCH 3/3] Update index.js --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 1b2844e7..581cd1de 100644 --- a/index.js +++ b/index.js @@ -119,7 +119,8 @@ // Touch events window.addEventListener('touchend', this.onMouseUp, { passive: false }); // Touch up window.addEventListener('touchmove', this.onMouseMove, { passive: false }); // Touch move - + + // Prevent context menu window.addEventListener('contextmenu', this.preventDefault); }, onMouseUp: function (event) {