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

16 lines
367 B
TypeScript
Raw Normal View History

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