Skip to content

Commit

Permalink
fix: createTooltip().show()
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Apr 5, 2022
1 parent c5f50e0 commit 56bc9d2
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
7 changes: 7 additions & 0 deletions packages/demo-vue3/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ export const demos = [
label: 'Directive manual',
},
},
{
path: '/directive/create-tooltip',
component: () => import('./views/directive/CreateTooltip.vue'),
meta: {
label: 'createTooltip',
},
},
{
path: '/component/demo1',
component: () => import('./views/component/DropdownDemo1.vue'),
Expand Down
32 changes: 32 additions & 0 deletions packages/demo-vue3/src/views/directive/CreateTooltip.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<script setup>
import { createTooltip, destroyTooltip } from 'floating-vue'
function clipboardSuccess (el) {
el.classList.add('copied')
const tooltip = createTooltip(el, {
triggers: [],
content: 'Copied!',
delay: 0,
})
tooltip.show()
setTimeout(() => {
el.classList.remove('copied')
tooltip.hide()
// Transition
setTimeout(() => {
destroyTooltip(el)
}, 400)
}, 600)
}
</script>

<template>
<div>
<button
class="px-4 py-2 bg-green-100 rounded"
@click="clipboardSuccess($event.currentTarget)"
>
Copy
</button>
</div>
</template>
4 changes: 2 additions & 2 deletions packages/floating-vue/src/directives/v-tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function ensureDirectiveApp () {
return this.directives.map((directive) => {
return h(TooltipDirective, {
...directive.options,
shown: directive.shown.value || directive.options.shown,
shown: directive.shown || directive.options.shown,
key: directive.id,
})
})
Expand Down Expand Up @@ -126,7 +126,7 @@ export function destroyTooltip (el) {
}
}

export function bind (el, { value, oldValue, modifiers }) {
export function bind (el, { value, modifiers }) {
const options = getOptions(el, value, modifiers)
if (!options.content || getDefaultConfig(options.theme || 'tooltip', 'disabled')) {
destroyTooltip(el)
Expand Down

0 comments on commit 56bc9d2

Please sign in to comment.