Skip to content

Commit

Permalink
fix(tab-bar): supplement scrolling of the first and last options (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
xxyan0205 authored May 25, 2019
1 parent 4d123b8 commit 1199da6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions components/tab-bar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,19 @@ export default {
const prevTarget = this.$refs.items[this.currentIndex - 1]
const nextTarget = this.$refs.items[this.currentIndex + 1]
if (!prevTarget) {
this.$refs.scroller.scrollTo(0, 0, true)
return
}
if (!nextTarget) {
this.$refs.scroller.scrollTo(this.wrapperW, 0, true)
return
}
const wrapperRect = this.$refs.wrapper.getBoundingClientRect()
const prevTargetRect = prevTarget && prevTarget.getBoundingClientRect()
const nextTargetRect = nextTarget && nextTarget.getBoundingClientRect()
const prevTargetRect = prevTarget.getBoundingClientRect()
const nextTargetRect = nextTarget.getBoundingClientRect()
/* istanbul ignore next */
if (prevTargetRect && prevTargetRect.left < wrapperRect.left) {
Expand Down

0 comments on commit 1199da6

Please sign in to comment.