Skip to content

Commit

Permalink
Merge pull request #34 from limichange/patch-1
Browse files Browse the repository at this point in the history
refactor(tabs): simplified conditional expression
  • Loading branch information
jimczj authored Aug 30, 2018
2 parents 3791d95 + a2d6717 commit c68b842
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 = touchMove - this.touchDot

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

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

Expand Down

0 comments on commit c68b842

Please sign in to comment.