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:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+12
-4
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user