Skip to content

Commit

Permalink
🐛 [bug]fix the current date is not between the maximum and the minimu…
Browse files Browse the repository at this point in the history
…m date.(#17)
  • Loading branch information
lanjingling0510 committed Apr 24, 2018
1 parent 8689f45 commit 99ce5da
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17,880 deletions.
7 changes: 5 additions & 2 deletions lib/DatePickerItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class DatePickerItem extends Component<void, Props, State> {
this.touchY = 0; // 保存touchstart的pageY
this.translateY = 0; // 容器偏移的距离
this.currentIndex = MIDDLE_INDEX; // 滑动中当前日期的索引
this.moveDateCount = 0; // 一次滑动移动了多少个时间

this.state = {
translateY: MIDDLE_Y,
Expand Down Expand Up @@ -180,9 +181,9 @@ class DatePickerItem extends Component<void, Props, State> {
_moveToNext(direction) {
const date = this.state.dates[MIDDLE_INDEX];
const { max, min } = this.props;
if (direction === -1 && date.getTime() < min.getTime()) {
if (direction === -1 && date.getTime() < min.getTime() && this.moveDateCount) {
this._updateDates(1);
} else if (direction === 1 && date.getTime() > max.getTime()) {
} else if (direction === 1 && date.getTime() > max.getTime() && this.moveDateCount) {
this._updateDates(-1);
}

Expand Down Expand Up @@ -220,6 +221,7 @@ class DatePickerItem extends Component<void, Props, State> {
event.pageY;

this.translateY = this.state.translateY;
this.moveDateCount = 0;
}


Expand All @@ -244,6 +246,7 @@ class DatePickerItem extends Component<void, Props, State> {

// 检测是否更新日期列表
if (this._checkIsUpdateDates(direction, translateY)) {
this.moveDateCount = direction > 0 ? this.moveDateCount + 1 : this.moveDateCount - 1;
this._updateDates(direction);
}

Expand Down
Loading

0 comments on commit 99ce5da

Please sign in to comment.