fix[TagsView]: fix openMenu boundary display bug (#1256)

This commit is contained in:
花裤衩 2018-10-25 10:42:18 +08:00 committed by GitHub
parent 1a345a7c65
commit cbdad9cb1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -121,11 +121,21 @@ export default {
this.$router.push('/')
},
openMenu(tag, e) {
const menuMinWidth = 105
const offsetLeft = this.$el.getBoundingClientRect().left // container margin left
const offsetWidth = this.$el.offsetWidth // container width
const maxLeft = offsetWidth - menuMinWidth // left boundary
const left = e.clientX - offsetLeft + 15 // 15: margin right
if (left > maxLeft) {
this.left = maxLeft
} else {
this.left = left
}
this.top = e.clientY
this.visible = true
this.selectedTag = tag
const offsetLeft = this.$el.getBoundingClientRect().left // container margin left
this.left = e.clientX - offsetLeft + 15 // 15: margin right
this.top = e.clientY
},
closeMenu() {
this.visible = false