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..581cd1de 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, @@ -114,9 +117,10 @@ 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 + // Prevent context menu window.addEventListener('contextmenu', this.preventDefault); }, onMouseUp: function (event) {