From 89d6a9bccacdf53be3727f00277cb00976ff1997 Mon Sep 17 00:00:00 2001 From: Francisco Madeira Date: Sat, 2 Oct 2021 03:55:36 +0100 Subject: [PATCH] Add modifieres for placement and arrow --- src/directive/index.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/directive/index.ts b/src/directive/index.ts index fe0f150..343dcec 100644 --- a/src/directive/index.ts +++ b/src/directive/index.ts @@ -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)