misskey-awawa/src/client/app/desktop/api/contextmenu.ts

16 lines
367 B
TypeScript
Raw Normal View History

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