Skip to content

Commit bf2bb49

Browse files
committed
feat: add popper methods show/hide to createTooltip()
1 parent 0752603 commit bf2bb49

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/docs/src/.vuepress/enhanceApp.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import 'v-tooltip/dist/v-tooltip.css'
8-
import VTooltipPlugin from 'v-tooltip'
8+
import VTooltipPlugin, { createTooltip } from 'v-tooltip'
99

1010
export default ({
1111
Vue, // the version of Vue being used in the VuePress app
@@ -30,4 +30,8 @@ export default ({
3030
},
3131
},
3232
})
33+
34+
if (typeof window !== 'undefined') {
35+
window.createTooltip = createTooltip
36+
}
3337
}

packages/v-tooltip/src/directives/v-tooltip.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Vue from 'vue'
22
import { placements } from '@popperjs/core'
33
import TooltipDirective from '../components/TooltipDirective.vue'
44
import { getDefaultConfig } from '../config'
5+
import PopperMethods from '../components/PopperMethods'
56

67
const TARGET_CLASS = 'v-popper--has-tooltip'
78

@@ -43,6 +44,9 @@ export function createTooltip (el, value, modifiers) {
4344
const options = getOptions(el, value, modifiers)
4445

4546
const tooltipApp = el.$_popper = new Vue({
47+
mixins: [
48+
PopperMethods,
49+
],
4650
data () {
4751
return {
4852
options,
@@ -65,7 +69,7 @@ export function createTooltip (el, value, modifiers) {
6569
loadingContent,
6670
},
6771
attrs: otherOptions,
68-
ref: 'tooltip',
72+
ref: 'popper',
6973
})
7074
},
7175
devtools: {

0 commit comments

Comments
 (0)