File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
src/views/layout/components Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -121,11 +121,21 @@ export default {
121
121
this .$router .push (' /' )
122
122
},
123
123
openMenu (tag , e ) {
124
- this .visible = true
125
- this .selectedTag = tag
124
+ const menuMinWidth = 105
126
125
const offsetLeft = this .$el .getBoundingClientRect ().left // container margin left
127
- this .left = e .clientX - offsetLeft + 15 // 15: margin right
126
+ const offsetWidth = this .$el .offsetWidth // container width
127
+ const maxLeft = offsetWidth - menuMinWidth // left boundary
128
+ const left = e .clientX - offsetLeft + 15 // 15: margin right
129
+
130
+ if (left > maxLeft) {
131
+ this .left = maxLeft
132
+ } else {
133
+ this .left = left
134
+ }
128
135
this .top = e .clientY
136
+
137
+ this .visible = true
138
+ this .selectedTag = tag
129
139
},
130
140
closeMenu () {
131
141
this .visible = false
You can’t perform that action at this time.
0 commit comments