@@ -34,6 +34,26 @@ export default class DraggableCore extends React.Component {
3434 static displayName = 'DraggableCore' ;
3535
3636 static propTypes = {
37+ /**
38+ * `disabled`, if true, stops the <Draggable> from dragging. All handlers,
39+ * with the exception of `onMouseDown`, will not fire.
40+ *
41+ * Example:
42+ *
43+ * ```jsx
44+ * let App = React.createClass({
45+ * render: function () {
46+ * return (
47+ * <Draggable disabled={true}>
48+ * <div>I can't be dragged</div>
49+ * </Draggable>
50+ * );
51+ * }
52+ * });
53+ * ```
54+ */
55+ disabled : PropTypes . bool ,
56+
3757 /**
3858 * By default, we add 'user-select:none' attributes to the document body
3959 * to prevent ugly text selection during drag. If this is causing problems
@@ -162,9 +182,10 @@ export default class DraggableCore extends React.Component {
162182 } ;
163183
164184 static defaultProps = {
165- handle : null ,
166185 cancel : null ,
186+ disabled : false ,
167187 enableUserSelectHack : true ,
188+ handle : null ,
168189 transform : null ,
169190 onStart : function ( ) { } ,
170191 onDrag : function ( ) { } ,
@@ -193,7 +214,8 @@ export default class DraggableCore extends React.Component {
193214 this . props . onMouseDown ( e ) ;
194215
195216 // Short circuit if handle or cancel prop was provided and selector doesn't match.
196- if ( ( this . props . handle && ! matchesSelector ( e . target , this . props . handle ) ) ||
217+ if ( this . props . disabled ||
218+ ( this . props . handle && ! matchesSelector ( e . target , this . props . handle ) ) ||
197219 ( this . props . cancel && matchesSelector ( e . target , this . props . cancel ) ) ) {
198220 return ;
199221 }
0 commit comments