Skip to content

Commit

Permalink
get or create div.tooltip, improving readability
Browse files Browse the repository at this point in the history
  • Loading branch information
bryan-brancotte committed May 6, 2021
1 parent d4100de commit 2d8d8fb
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions js/tree-reusable-d3.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,8 @@ function interactive_tree() {
.call(zoom);
var vis = svg.append("svg:g");

/* jshint -W014 */
var tooltip = (d3.select("body").select("div.tooltip").empty() /* if no div.tooltip*/
?d3.select("body").append("div") /* then create one */
:d3.select("body").select("div.tooltip") /* otherwise use existing div.tooltip */
)
var body = d3.select("body");
var tooltip = (body.select("div.tooltip").empty() ? body.append("div") : body.select("div.tooltip"))
.attr("class", "tooltip")
.style("opacity", 0)
.on("mouseover", function(d) {
Expand Down

0 comments on commit 2d8d8fb

Please sign in to comment.