@@ -54,10 +54,19 @@ class DatePicker extends Component {
5454 _moveToNext ( direction ) {
5555 const scroll = this . refs . scroll ;
5656 const angle = this . angle ;
57- if ( direction === 1 ) {
58- this . _moveTo ( scroll , angle + 22.5 ) ;
57+ const { maxDate, minDate } = this . props ;
58+
59+ const date = ( direction === 1 ) ?
60+ this . state . dates . find ( value =>
61+ value . value . getTime ( ) > nextTime ( maxDate , 0 ) . getTime ( ) &&
62+ angle + direction * 22.5 + value . angle === 0 ) :
63+ this . state . dates . find ( value =>
64+ value . value . getTime ( ) < nextTime ( minDate , 0 ) . getTime ( ) &&
65+ angle + direction * 22.5 + value . angle === 0 ) ;
66+ if ( date ) {
67+ this . _moveTo ( scroll , angle ) ;
5968 } else {
60- this . _moveTo ( scroll , angle - 22.5 ) ;
69+ this . _moveTo ( scroll , angle + direction * 22.5 ) ;
6170 }
6271 }
6372
@@ -134,7 +143,7 @@ class DatePicker extends Component {
134143 }
135144
136145 render ( ) {
137- const { layerBackground } = this . props ;
146+ const { layerBackground, btnColor } = this . props ;
138147 const scrollStyle = {
139148 [ TRANSFORM ] : `rotateX(${ this . state . angle } deg)` ,
140149 } ;
@@ -150,6 +159,7 @@ class DatePicker extends Component {
150159 style = { datePickerStyle } >
151160 < p className = "datepicker-navbar" >
152161 < span
162+ style = { { color : btnColor } }
153163 className = "datepicker-finish-btn"
154164 onClick = { this . handleFinishBtnClick } > 完成</ span >
155165 </ p >
@@ -180,24 +190,22 @@ DatePicker.propTypes = {
180190 dateColor : PropTypes . string ,
181191 layerBackground : PropTypes . string ,
182192 isOpen : PropTypes . bool ,
183- startDate : PropTypes . oneOfType ( [
184- PropTypes . object ,
185- PropTypes . number ,
186- ] ) ,
187- minDate : PropTypes . oneOfType ( [
188- PropTypes . object ,
189- PropTypes . number ,
190- ] ) ,
193+ startDate : PropTypes . object ,
194+ minDate : PropTypes . object ,
195+ maxDate : PropTypes . object ,
191196 onSelect : PropTypes . func ,
192197 onCancel : PropTypes . func ,
193198} ;
194199
195200DatePicker . defaultProps = {
196201 touchLen : 40 ,
197202 dateColor : '#fff' ,
203+ btnColor : '#fff' ,
204+ isOpen : true ,
198205 layerBackground : '#ffa70b' ,
199- startDate : new Date ( ) ,
200- minDate : new Date ( 2016 , 3 , 7 ) ,
206+ startDate : nextTime ( new Date ( ) , 0 ) ,
207+ minDate : nextTime ( new Date ( ) , - 30 ) ,
208+ maxDate : nextTime ( new Date ( ) , 0 ) ,
201209 onSelect : ( ) => { } ,
202210 onCancel : ( ) => { } ,
203211} ;
0 commit comments