Sharkey/src/client/app/desktop/api/contextmenu.ts

16 lines
367 B
TypeScript
Raw Normal View History

2018-05-27 12:12:39 +03:00
import OS from '../../mios';
2018-02-18 05:35:18 +02:00
import Ctx from '../views/components/context-menu.vue';
2018-05-27 12:12:39 +03:00
export default (os: OS) => (e, menu, opts?) => {
2018-02-18 05:35:18 +02:00
const o = opts || {};
2018-05-27 12:12:39 +03:00
const vm = os.new(Ctx, {
menu,
x: e.pageX - window.pageXOffset,
y: e.pageY - window.pageYOffset,
});
2018-02-18 05:35:18 +02:00
vm.$once('closed', () => {
if (o.closed) o.closed();
});
document.body.appendChild(vm.$el);
2018-05-27 12:12:39 +03:00
};