Skip to content

Commit

Permalink
refactor: simplified conditional expression
Browse files Browse the repository at this point in the history
  • Loading branch information
limichange authored Aug 30, 2018
1 parent acdc676 commit d0facb0
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/components/tabs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,19 @@ class AtTabs extends AtComponent {

const { current } = this.props
const touchMove = e.touches[0].pageX
// 向左滑动
if (!this.isMoving && current + 1 < this.maxIndex && touchMove - this.touchDot <= -40 && this.time < 10) {
this.isMoving = true
this.handleClick(current + 1)
}
// 向右滑动
if (!this.isMoving && current - 1 >= 0 && touchMove - this.touchDot >= 40 && this.time < 10) {
this.isMoving = true
this.handleClick(current - 1)
const moveDistance = Math.abs(touchMove - this.touchDot)

if (!this.isMoving && this.time < 10 && moveDistance >= 40) {
// 向左滑动
if (current + 1 < this.maxIndex) {
this.isMoving = true
this.handleClick(current + 1)

// 向右滑动
} else if (current - 1 >= 0) {
this.isMoving = true
this.handleClick(current - 1)
}
}
}

Expand Down

0 comments on commit d0facb0

Please sign in to comment.