This commit is contained in:
zhigang.li 2018-08-10 12:12:06 +08:00
parent 4f6b766830
commit af3e7d0258
1 changed files with 13 additions and 0 deletions

View File

@ -103,6 +103,18 @@ export default {
},
showTitleInside (item) {
return showTitle(item, this)
},
moveToView (tag) {
if (tag.offsetLeft < -this.tagBodyLeft) {
//
this.tagBodyLeft = -tag.offsetLeft + 10
} else if (tag.offsetLeft + 10 > -this.tagBodyLeft && tag.offsetLeft + tag.offsetWidth < -this.tagBodyLeft + this.$refs.scrollCon.offsetWidth - 100) {
//
this.tagBodyLeft = Math.min(0, this.$refs.scrollCon.offsetWidth - 100 - tag.offsetWidth - tag.offsetLeft - 20)
} else {
//
this.tagBodyLeft = -(tag.offsetLeft - (this.$refs.scrollCon.offsetWidth - 100 - tag.offsetWidth) + 20)
}
}
},
mounted () {
@ -112,6 +124,7 @@ export default {
console.log(this.$route.name, item.name)
if (this.$route.name === item.name) {
let tag = this.refsTag[index].$el
console.log(tag)
this.moveToView(tag)
}
})