dropdown menu implementation

This commit is contained in:
Jan Prochazka
2021-02-28 10:17:52 +01:00
parent e9430988f4
commit 2cc74b594e
7 changed files with 122 additions and 1 deletions

View File

@@ -0,0 +1,19 @@
import _ from 'lodash';
import { currentDropDownMenu } from '../stores';
export default function contextMenu(node, items) {
const handleContextMenu = e => {
e.preventDefault();
const left = e.pageX;
const top = e.pageY;
currentDropDownMenu.set({ left, top, items: _.isFunction(items) ? items() : items });
};
node.addEventListener('contextmenu', handleContextMenu);
return {
destroy() {
node.removeEventListener('contextmenu', handleContextMenu);
},
};
}