} else {
context._leave()
}
- } else {
- if (this._getTipElement().classList.contains(CLASS_NAME_SHOW)) {
- this._leave()
- return
- }
- this._enter()
+ return
+ }
+
+ if (this._isShown()) {
+ this._leave()
+ return
}
+
+ this._enter()
}
dispose() {
if (this._popper) {
this._popper.update()
} else {
- const placement = typeof this._config.placement === 'function' ?
- this._config.placement.call(this, tip, this._element) :
- this._config.placement
- const attachment = AttachmentMap[placement.toUpperCase()]
- this._popper = Popper.createPopper(this._element, tip, this._getPopperConfig(attachment))
+ this._createPopper(tip)
}
tip.classList.add(CLASS_NAME_SHOW)
}
hide() {
- if (!this._popper) {
+ if (!this._isShown()) {
return
}
this._activeTrigger[TRIGGER_CLICK] = false
this._activeTrigger[TRIGGER_FOCUS] = false
this._activeTrigger[TRIGGER_HOVER] = false
+ this._isHovered = false
const complete = () => {
if (this._isWithActiveTrigger()) {
}
this._queueCallback(complete, this.tip, this._isAnimated())
- this._isHovered = false
}
update() {
setContent(content) {
let isShown = false
if (this.tip) {
- isShown = this.tip.classList.contains(CLASS_NAME_SHOW)
+ isShown = this._isShown()
this.tip.remove()
this.tip = null
}
return this._config.animation || (this.tip && this.tip.classList.contains(CLASS_NAME_FADE))
}
+ _isShown() {
+ return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW)
+ }
+
+ _createPopper(tip) {
+ const placement = typeof this._config.placement === 'function' ?
+ this._config.placement.call(this, tip, this._element) :
+ this._config.placement
+ const attachment = AttachmentMap[placement.toUpperCase()]
+ this._popper = Popper.createPopper(this._element, tip, this._getPopperConfig(attachment))
+ }
+
_getOffset() {
const { offset } = this._config
}
_enter() {
- if (this._getTipElement().classList.contains(CLASS_NAME_SHOW) || this._isHovered) {
+ if (this._isShown() || this._isHovered) {
this._isHovered = true
return
}