Skip to content

Commit

Permalink
fix[TagsView]: fix openMenu boundary display bug (PanJiaChen#1256)
Browse files Browse the repository at this point in the history
  • Loading branch information
PanJiaChen authored Oct 25, 2018
1 parent 1a345a7 commit cbdad9c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/views/layout/components/TagsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,21 @@ export default {
this.$router.push('/')
},
openMenu(tag, e) {
this.visible = true
this.selectedTag = tag
const menuMinWidth = 105
const offsetLeft = this.$el.getBoundingClientRect().left // container margin left
this.left = e.clientX - offsetLeft + 15 // 15: margin right
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
},
closeMenu() {
this.visible = false
Expand Down

0 comments on commit cbdad9c

Please sign in to comment.