Skip to content

Commit

Permalink
Fixed Tooltip API compatibility. Don't hide sticked tooltip on mouse …
Browse files Browse the repository at this point in the history
…leave. Hide tooltip on resize.
  • Loading branch information
alexanderby committed Jan 12, 2017
1 parent ae23511 commit e4e10ba
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions plugins/tooltip.js
Expand Up @@ -49,6 +49,9 @@
this._metaInfo = {};
this._skipInfo = {};

// NOTE: for compatibility with old Tooltip implementation.
Object.assign(this, utils.omit(settings, 'fields', 'getFields'));

this._tooltip = this._chart.addBalloon(
{
spacing: 3,
Expand Down Expand Up @@ -109,10 +112,6 @@
this._tooltip
.getElement()
.addEventListener('mouseleave', function (e) {
this.setState({
highlight: null,
isStuck: false
});
this._removeFocus();
}.bind(this), false);

Expand All @@ -123,6 +122,7 @@
});
}.bind(this);
window.addEventListener('scroll', this._scrollHandler, true);
window.addEventListener('resize', this._scrollHandler, true);

this._outerClickHandler = function (e) {
var tooltipRect = this._tooltip.getElement().getBoundingClientRect();
Expand Down Expand Up @@ -175,7 +175,7 @@
} else {
showTooltip();
}
} else if (!state.isStuck) {
} else if (!state.isStuck && prev.highlight.data && !state.highlight.data) {
this.hideTooltip();
}
}
Expand Down Expand Up @@ -219,6 +219,7 @@

destroy: function () {
window.removeEventListener('scroll', this._scrollHandler, true);
window.removeEventListener('resize', this._scrollHandler, true);
window.removeEventListener('click', this._outerClickHandler, true);
this._removeFocus();
this._tooltip.destroy();
Expand Down

0 comments on commit e4e10ba

Please sign in to comment.