@@ -29,13 +29,15 @@ class DatePicker extends Component {
29
29
this . state = {
30
30
date : this . getDate ( ) ,
31
31
modalVisible : false ,
32
- animatedHeight : new Animated . Value ( 0 )
32
+ animatedHeight : new Animated . Value ( 0 ) ,
33
+ allowPointerEvents : true
33
34
} ;
34
35
35
36
this . datePicked = this . datePicked . bind ( this ) ;
36
37
this . onPressDate = this . onPressDate . bind ( this ) ;
37
38
this . onPressCancel = this . onPressCancel . bind ( this ) ;
38
39
this . onPressConfirm = this . onPressConfirm . bind ( this ) ;
40
+ this . onDateChange = this . onDateChange . bind ( this ) ;
39
41
this . onPressMask = this . onPressMask . bind ( this ) ;
40
42
this . onDatePicked = this . onDatePicked . bind ( this ) ;
41
43
this . onTimePicked = this . onTimePicked . bind ( this ) ;
@@ -174,6 +176,19 @@ class DatePicker extends Component {
174
176
return ( < Text style = { [ Style . dateText , customStyles . dateText ] } > { this . getDateStr ( ) } </ Text > ) ;
175
177
}
176
178
179
+ onDateChange ( date ) {
180
+ this . setState ( {
181
+ allowPointerEvents : false ,
182
+ date : date
183
+ } )
184
+ const timeoutId = setTimeout ( ( ) => {
185
+ this . setState ( {
186
+ allowPointerEvents : true
187
+ } )
188
+ clearTimeout ( timeoutId )
189
+ } , 500 )
190
+ }
191
+
177
192
onDatePicked ( { action, year, month, day} ) {
178
193
if ( action !== DatePickerAndroid . dismissedAction ) {
179
194
this . setState ( {
@@ -354,16 +369,18 @@ class DatePicker extends Component {
354
369
< Animated . View
355
370
style = { [ Style . datePickerCon , { height : this . state . animatedHeight } , customStyles . datePickerCon ] }
356
371
>
357
- < DatePickerIOS
358
- date = { this . state . date }
359
- mode = { mode }
360
- minimumDate = { minDate && this . getDate ( minDate ) }
361
- maximumDate = { maxDate && this . getDate ( maxDate ) }
362
- onDateChange = { ( date ) => this . setState ( { date : date } ) }
363
- minuteInterval = { minuteInterval }
364
- timeZoneOffsetInMinutes = { timeZoneOffsetInMinutes }
365
- style = { [ Style . datePicker , customStyles . datePicker ] }
366
- />
372
+ < View pointerEvents = { this . state . allowPointerEvents ? 'auto' : 'none' } >
373
+ < DatePickerIOS
374
+ date = { this . state . date }
375
+ mode = { mode }
376
+ minimumDate = { minDate && this . getDate ( minDate ) }
377
+ maximumDate = { maxDate && this . getDate ( maxDate ) }
378
+ onDateChange = { this . onDateChange }
379
+ minuteInterval = { minuteInterval }
380
+ timeZoneOffsetInMinutes = { timeZoneOffsetInMinutes }
381
+ style = { [ Style . datePicker , customStyles . datePicker ] }
382
+ />
383
+ </ View >
367
384
< TouchableHighlight
368
385
underlayColor = { 'transparent' }
369
386
onPress = { this . onPressCancel }
0 commit comments