Optimize Tabs contextMenu
This commit is contained in:
parent
e3d2e05598
commit
0a3ea18b48
1 changed files with 15 additions and 12 deletions
|
@ -332,19 +332,22 @@
|
|||
this.$emit('on-dblclick', nav.name);
|
||||
},
|
||||
handleContextmenu (index, event) {
|
||||
const nav = this.navList[index];
|
||||
if (!nav || nav.disabled || !nav.contextMenu) return;
|
||||
if (this.contextMenuVisible) this.handleClickContextMenuOutside();
|
||||
this.$nextTick(() => {
|
||||
const nav = this.navList[index];
|
||||
if (!nav || nav.disabled || !nav.contextMenu) return;
|
||||
|
||||
event.preventDefault();
|
||||
const $TabsWrap = this.$refs.tabsWrap;
|
||||
const TabsBounding = $TabsWrap.getBoundingClientRect();
|
||||
const position = {
|
||||
left: `${event.clientX - TabsBounding.left}px`,
|
||||
top: `${event.clientY - TabsBounding.top}px`
|
||||
};
|
||||
this.contextMenuStyles = position;
|
||||
this.contextMenuVisible = true;
|
||||
this.$emit('on-contextmenu', nav, event, position);
|
||||
event.preventDefault();
|
||||
const $TabsWrap = this.$refs.tabsWrap;
|
||||
const TabsBounding = $TabsWrap.getBoundingClientRect();
|
||||
const position = {
|
||||
left: `${event.clientX - TabsBounding.left}px`,
|
||||
top: `${event.clientY - TabsBounding.top}px`
|
||||
};
|
||||
this.contextMenuStyles = position;
|
||||
this.contextMenuVisible = true;
|
||||
this.$emit('on-contextmenu', nav, event, position);
|
||||
});
|
||||
},
|
||||
handleClickContextMenuOutside () {
|
||||
this.contextMenuVisible = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue