Add v-contextmenu directive
This commit is contained in:
parent
c2ccfd02da
commit
697df8a7fe
|
@ -39,11 +39,11 @@
|
|||
this.top = window.innerHeight - this.mouseY - height < 0 ? this.mouseY - height : this.mouseY;
|
||||
this.left = window.innerWidth - this.mouseX - 170 < 0 ? this.mouseX - 170 : this.mouseX;
|
||||
this.renderLeft = (this.left + 170 * 2) > window.innerWidth;
|
||||
window.addEventListener('mouseup', this.clickHide);
|
||||
window.addEventListener('mousedown', this.clickHide);
|
||||
return { top: `${this.top}px`, left: `${this.left}px` };
|
||||
},
|
||||
hide() {
|
||||
window.removeEventListener('mouseup', this.clickHide);
|
||||
window.removeEventListener('mousedown', this.clickHide);
|
||||
this.activeMenu.menu = null;
|
||||
},
|
||||
clickHide(e) {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import { Utils } from 'common';
|
||||
import { Utils, ClientLogger as Logger } from 'common';
|
||||
import { ReactComponents, WebpackModules, MonkeyPatch } from 'modules';
|
||||
import { VueInjector, Toasts } from 'ui';
|
||||
import CMGroup from './components/contextmenu/Group.vue';
|
||||
|
@ -30,6 +30,17 @@ export class BdContextMenu {
|
|||
return this._activeMenu || (this._activeMenu = { menu: null });
|
||||
}
|
||||
|
||||
static install(Vue) {
|
||||
Vue.directive('contextmenu', {
|
||||
bind(el, binding) {
|
||||
el.addEventListener('contextmenu', event => {
|
||||
Logger.log('BdContextMenu', ['Showing context menu', event, el, binding]);
|
||||
BdContextMenu.show(event, binding.value);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class DiscordContextMenu {
|
||||
|
|
|
@ -12,6 +12,7 @@ import Vue from 'vue';
|
|||
import VTooltip from 'v-tooltip';
|
||||
import DOM from './dom';
|
||||
import VueInjector from './vueinjector';
|
||||
import { BdContextMenu } from './contextmenus';
|
||||
|
||||
Vue.use(VTooltip, {
|
||||
defaultContainer: 'bd-tooltips',
|
||||
|
@ -46,5 +47,6 @@ Vue.use(VTooltip, {
|
|||
});
|
||||
|
||||
Vue.use(VueInjector);
|
||||
Vue.use(BdContextMenu);
|
||||
|
||||
export default Vue;
|
||||
|
|
Loading…
Reference in New Issue