Commit c0e70ff9 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

Massive performance improvement by changing tooltip init

parent f23b9445
......@@ -327,6 +327,8 @@
},
methods: {
getTippyInstances (label) {
const event = document.createEvent('Event')
event.initEvent('mouseover', true, true)
return [
this.$el.querySelector(`.fjs-box[data-label="${label}"] .fjs-upper-whisker`),
this.$el.querySelector(`.fjs-box[data-label="${label}"] .fjs-lower-whisker`),
......@@ -334,6 +336,7 @@
this.$el.querySelector(`.fjs-box[data-label="${label}"] .fjs-lower-quartile`),
this.$el.querySelector(`.fjs-box[data-label="${label}"] .fjs-median`)
].map(el => {
el.dispatchEvent(event) // populate tooltips
const uuid = el.getAttribute('data-uuid')
return { el, tip: this._tippyInstances[uuid] }
})
......
......@@ -6,14 +6,18 @@ export default {
if (typeof vnode.context._tippyInstances === 'undefined') {
vnode.context._tippyInstances = {}
}
const uuid = uuid4()
el.setAttribute('data-uuid', uuid)
const tip = tippy(el, Object.assign({
performance: true,
arrow: true,
theme: 'light',
dynamicTitle: true
}, binding.value))
vnode.context._tippyInstances[uuid] = tip
const addTooltip = (event) => {
const uuid = uuid4()
el.setAttribute('data-uuid', uuid)
const target = event.target || event.srcElement
vnode.context._tippyInstances[uuid] = tippy(target, Object.assign({
performance: true,
arrow: true,
theme: 'light',
dynamicTitle: true
}, binding.value))
el.removeEventListener('mouseover', addTooltip)
}
el.addEventListener('mouseover', addTooltip)
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment