@@ -51,6 +51,7 @@ let DaySlot = React.createClass({
51
51
selectable : React . PropTypes . bool ,
52
52
eventOffset : React . PropTypes . number ,
53
53
54
+ onSelecting : React . PropTypes . func ,
54
55
onSelectSlot : React . PropTypes . func . isRequired ,
55
56
onSelectEvent : React . PropTypes . func . isRequired
56
57
} ,
@@ -193,6 +194,24 @@ let DaySlot = React.createClass({
193
194
let node = findDOMNode ( this ) ;
194
195
let selector = this . _selector = new Selection ( ( ) => findDOMNode ( this ) )
195
196
197
+ let maybeSelect = ( box ) => {
198
+ let onSelecting = this . props . onSelecting
199
+ let current = this . state || { } ;
200
+ let state = selectionState ( box ) ;
201
+ let { startDate : start , endDate : end } = state ;
202
+
203
+ if ( onSelecting ) {
204
+ if (
205
+ ( dates . eq ( current . startDate , start , 'minutes' ) &&
206
+ dates . eq ( current . endDate , end , 'minutes' ) ) ||
207
+ onSelecting ( { start, end } ) === false
208
+ )
209
+ return
210
+ }
211
+
212
+ this . setState ( state )
213
+ }
214
+
196
215
let selectionState = ( { x, y } ) => {
197
216
let { step, min, max } = this . props ;
198
217
let { top, bottom } = getBoundsForNode ( node )
@@ -225,11 +244,8 @@ let DaySlot = React.createClass({
225
244
}
226
245
}
227
246
228
- selector . on ( 'selecting' ,
229
- box => this . setState ( selectionState ( box ) ) )
230
-
231
- selector . on ( 'selectStart' ,
232
- box => this . setState ( selectionState ( box ) ) )
247
+ selector . on ( 'selecting' , maybeSelect )
248
+ selector . on ( 'selectStart' , maybeSelect )
233
249
234
250
selector
235
251
. on ( 'click' , ( { x, y } ) => {
@@ -242,8 +258,10 @@ let DaySlot = React.createClass({
242
258
243
259
selector
244
260
. on ( 'select' , ( ) => {
245
- this . _selectSlot ( this . state )
246
- this . setState ( { selecting : false } )
261
+ if ( this . state . selecting ) {
262
+ this . _selectSlot ( this . state )
263
+ this . setState ( { selecting : false } )
264
+ }
247
265
} )
248
266
} ,
249
267
0 commit comments