Add modifieres for placement and arrow

This commit is contained in:
Francisco Madeira
2021-10-02 03:55:36 +01:00
parent 0a0e6f6832
commit 89d6a9bcca
+12
View File
@@ -5,6 +5,18 @@ const directive: Directive = {
mounted(el, binding, vnode) {
const opts = binding.value || {}
const modifiers = Object.keys(binding.modifiers || {})
const placement = modifiers.find(modifier => modifier !== 'arrow')
const withArrow = modifiers.findIndex(modifier => modifier === 'arrow') !== -1
if (placement) {
opts.placement = opts.placement || placement
}
if (withArrow) {
opts.arrow = opts.arrow !== undefined ? opts.arrow : true
}
if (vnode.props && vnode.props.onTippyShow) {
opts.onShow = function (...args: any[]) {
return vnode.props?.onTippyShow(...args)