2
0
mirror of https://github.com/tenrok/vue-context.git synced 2026-06-13 06:12:22 +03:00

Emit close and open events

This commit is contained in:
Randall Wilk
2018-10-15 08:55:20 -05:00
parent 640980b8bf
commit d157ffc746
2 changed files with 13 additions and 5 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+12 -4
View File
@@ -45,7 +45,7 @@
return this.show
? { top: `${this.top}px`, left: `${this.left}px` }
: null;
},
}
},
data () {
@@ -79,12 +79,18 @@
/**
* Close the context menu.
*
* @param {boolean|Event} emit Used to prevent event being emitted twice from when menu is clicked and closed
*/
close () {
close (emit = true) {
this.top = null;
this.left = null;
this.data = null;
this.show = false;
if (emit) {
this.$emit('close');
}
},
/**
@@ -92,7 +98,7 @@
*/
onClick () {
if (this.closeOnClick) {
this.close();
this.close(false);
}
},
@@ -109,6 +115,8 @@
this.$nextTick(() => {
this.positionMenu(event.clientY, event.clientX);
this.$el.focus();
this.$emit('open', event, this.data, this.top, this.left);
});
},
@@ -200,4 +208,4 @@
}
}
}
</style>
</style>