Destroy all old background layer tooltips before making new ones

(closes #5551)
This commit is contained in:
Bryan Housel
2018-12-05 00:35:45 -05:00
parent 4bfc78c69b
commit bee01d8497
2 changed files with 12 additions and 4 deletions

View File

@@ -52,6 +52,8 @@ export function uiBackground(context) {
var description = d.description();
var isOverflowing = (span.property('clientWidth') !== span.property('scrollWidth'));
item.call(tooltip().destroyAny);
if (d === _previousBackground) {
item.call(tooltip()
.placement(placement)
@@ -66,8 +68,6 @@ export function uiBackground(context) {
.placement(placement)
.title(description || d.name())
);
} else {
item.call(tooltip().destroy);
}
});
}

View File

@@ -69,7 +69,10 @@ export function tooltip() {
};
tooltip.destroy = function(selection) {
tooltip.destroy = function(selection, selector) {
// by default, just destroy the current tooltip
selector = selector || '.tooltip-' + _id;
selection
.on('mouseenter.tooltip', null)
.on('mouseleave.tooltip', null)
@@ -77,11 +80,16 @@ export function tooltip() {
return this.getAttribute('data-original-title') || this.getAttribute('title');
})
.attr('data-original-title', null)
.selectAll('.tooltip-' + _id)
.selectAll(selector)
.remove();
};
tooltip.destroyAny = function(selection) {
selection.call(tooltip.destroy, '.tooltip');
};
function setup() {
var root = d3_select(this);
var animate = _animation.apply(this, arguments);