mirror of
https://github.com/tenrok/vue-context.git
synced 2026-06-24 04:40:33 +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
|
return this.show
|
||||||
? { top: `${this.top}px`, left: `${this.left}px` }
|
? { top: `${this.top}px`, left: `${this.left}px` }
|
||||||
: null;
|
: null;
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
data () {
|
data () {
|
||||||
@@ -79,12 +79,18 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the context menu.
|
* 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.top = null;
|
||||||
this.left = null;
|
this.left = null;
|
||||||
this.data = null;
|
this.data = null;
|
||||||
this.show = false;
|
this.show = false;
|
||||||
|
|
||||||
|
if (emit) {
|
||||||
|
this.$emit('close');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,7 +98,7 @@
|
|||||||
*/
|
*/
|
||||||
onClick () {
|
onClick () {
|
||||||
if (this.closeOnClick) {
|
if (this.closeOnClick) {
|
||||||
this.close();
|
this.close(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -109,6 +115,8 @@
|
|||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.positionMenu(event.clientY, event.clientX);
|
this.positionMenu(event.clientY, event.clientX);
|
||||||
this.$el.focus();
|
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