From 0b89df063ffc4141f160c4ce8dda8e46dfdb52d3 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Fri, 8 Feb 2013 11:02:23 -0500 Subject: [PATCH] Optimize resetting opacity --- js/id/svg/labels.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/js/id/svg/labels.js b/js/id/svg/labels.js index 883147d3e..dd26072f8 100644 --- a/js/id/svg/labels.js +++ b/js/id/svg/labels.js @@ -212,15 +212,25 @@ iD.svg.Labels = function(projection) { containsLabel = iD.util.trueObj(labels), selection = d3.select(this); + // ensures that simply resetting opacity + // does not force style recalculation + function resetOpacity() { + if (this._opacity !== '') { + this.style.opacity = ''; + this._opacity = ''; + } + } + selection.selectAll('.layer-label text, .layer-halo path, .layer-halo rect') - .style('opacity', ''); + .each(resetOpacity); if (!labels.length) return; selection.selectAll('.layer-label text, .layer-halo path, .layer-halo rect') .filter(function(d) { return containsLabel[d.id]; }) - .style('opacity', 0); + .style('opacity', 0) + .property('_opacity', 0); } var rtree = new RTree(),