rewrite popover because v-tooltip is slow as heck

This commit is contained in:
Shpuld Shpuldson 2020-02-12 19:22:40 +02:00
commit 5262676e0e
13 changed files with 417 additions and 168 deletions

31
src/modules/popover.js Normal file
View file

@ -0,0 +1,31 @@
import { omit } from 'lodash'
import { set } from 'vue'
const popover = {
state: {
popovers: {}
},
mutations: {
registerPopover (state, { id, el }) {
set(state.popovers, id, el)
},
unregisterPopover (state, { id }) {
state.popovers = omit(state.popovers, id)
}
},
actions: {
registerPopover (store, el) {
// Generate unique id, it will be used to link portal and portal-target
// popover-target will make portal targets for each registered popover
// el will be used by popover target to put popovers in their places.
let id = Math.floor(Math.random() * 1000000).toString()
store.commit('registerPopover', { id, el })
return id
},
unregisterPopover (store, id) {
store.commit('unregisterPopover', { id })
}
}
}
export default popover