vue-tippy
Advanced tools
Comparing version 0.2.2 to 0.2.3
{ | ||
"name": "vue-tippy", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "vue-tippy.js", |
@@ -9,2 +9,6 @@ # vue-tippy | ||
#### CDN | ||
[unpkg.com](https://unpkg.com/vue-tippy/dist/vue-tippy.min.js) | ||
#### Available through npm as `vue-tippy`. | ||
@@ -16,2 +20,3 @@ | ||
``` | ||
@@ -52,2 +57,3 @@ ## Usage | ||
``` | ||
#### Bugs | ||
@@ -58,2 +64,2 @@ - Constant updating HTML or VueComponent will cause small delay for tooltip to pickup the new content, | ||
[MIT](http://opensource.org/licenses/MIT) | ||
[MIT](http://opensource.org/licenses/MIT) |
@@ -9,6 +9,34 @@ const Tippy = require('tippy.js'); | ||
getInstance: function (el) { | ||
return Vue.$tippyInstances.find(function ($instance) { | ||
return $instance.el === el; | ||
}); | ||
}, | ||
getTippyPopper: function (tippy) { | ||
return tippy.getPopperElement(tippy.selector) | ||
}, | ||
showPopper: function (el) { | ||
var tippy = this.getTippy(el); | ||
tippy.show(this.getTippyPopper(tippy)); | ||
}, | ||
hidePopper: function (el) { | ||
var tippy = this.getTippy(el); | ||
tippy.hide(this.getTippyPopper(tippy)); | ||
}, | ||
destroyTippy: function (el) { | ||
var i = this.getInstance(el); | ||
var t = this.getTippy(el).t; | ||
t.destroy(this.getTippyPopper(t)); | ||
var index = Vue.$tippyInstances.indexOf(i); | ||
if(index > -1) | ||
t.splice(index,1); | ||
}, | ||
getTippy: function (el) { | ||
return this.getInstance(el).tippy; | ||
}, | ||
update: function (el) { | ||
this.instance = Vue.$tippyInstances.find(function ($instance) { | ||
return $instance.el == el; | ||
}); | ||
this.instance = this.getInstance(el); | ||
if (this.instance) { | ||
@@ -39,10 +67,14 @@ this.instance.tippy.update(this.instance.tippy.getPopperElement(this.instance.tippy.selector)) | ||
inserted: function (el, binding, vnode, oldVnode) { | ||
const handlers = (vnode.data && vnode.data.on) || | ||
(vnode.componentOptions && vnode.componentOptions.listeners); | ||
el.tippy = new Tippy(el, { | ||
onShow: function () { | ||
if (handlers && handlers["show"]) { | ||
handlers["show"].fns(); | ||
} | ||
}, | ||
onShown: function () { | ||
const handlers = (vnode.data && vnode.data.on) || | ||
(vnode.componentOptions && vnode.componentOptions.listeners); | ||
if (handlers && handlers["shown"]) { | ||
@@ -52,2 +84,12 @@ handlers["shown"].fns(); | ||
}, | ||
onHidden: function () { | ||
if (handlers && handlers["hidden"]) { | ||
handlers["hidden"].fns(); | ||
} | ||
}, | ||
onHide: function () { | ||
if (handlers && handlers["hide"]) { | ||
handlers["hide"].fns(); | ||
} | ||
}, | ||
}); | ||
@@ -61,2 +103,5 @@ Vue.$tippyInstances.push({ | ||
}, | ||
unbind: function (el,binding,vnode) { | ||
vnode.context.$tippy.destroyTippy(el); | ||
}, | ||
componentUpdated: function (el) { | ||
@@ -63,0 +108,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
242046
3918
62