@@ -68,9 +68,9 @@ module.exports = React.createClass({
6868 * var App = React.createClass({
6969 * render: function () {
7070 * return (
71- * <Draggable handle="h2 ">
71+ * <Draggable handle=".handle ">
7272 * <div>
73- * <h2 >Click me to drag</h2 >
73+ * <div className="handle" >Click me to drag</div >
7474 * <div>This is some other content</div>
7575 * </div>
7676 * </Draggable>
@@ -81,6 +81,28 @@ module.exports = React.createClass({
8181 */
8282 handle : React . PropTypes . string ,
8383
84+ /**
85+ * `cancel` specifies a selector to be used to prevent drag initialization.
86+ *
87+ * Example:
88+ *
89+ * ```jsx
90+ * var App = React.createClass({
91+ * render: function () {
92+ * return(
93+ * <Draggable cancel=".cancel">
94+ * <div>
95+ * <div className="cancel">You can't drag from here</div>
96+ * <div>Dragging here works fine</div>
97+ * </div>
98+ * </Draggable>
99+ * );
100+ * }
101+ * });
102+ * ```
103+ */
104+ cancel : React . PropTypes . string ,
105+
84106 /**
85107 * Called when dragging starts.
86108 *
@@ -146,6 +168,7 @@ module.exports = React.createClass({
146168 return {
147169 axis : 'both' ,
148170 handle : null ,
171+ cancel : null ,
149172 onStart : emptyFunction ,
150173 onDrag : emptyFunction ,
151174 onStop : emptyFunction
@@ -171,7 +194,8 @@ module.exports = React.createClass({
171194 handleMouseDown : function ( e ) {
172195 var node = this . getDOMNode ( ) ;
173196
174- if ( this . props . handle && ! matchesSelector ( e . target , this . props . handle ) ) {
197+ if ( ( this . props . handle && ! matchesSelector ( e . target , this . props . handle ) ) ||
198+ ( this . props . cancel && matchesSelector ( e . target , this . props . cancel ) ) ) {
175199 return ;
176200 }
177201
0 commit comments