diff --git a/d3-tip.js b/d3-tip.js index ddc6100..4c74cd6 100644 --- a/d3-tip.js +++ b/d3-tip.js @@ -44,6 +44,7 @@ d3.tip = function() { scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft nodel.html(content) + .attr("keep_visible", "false") .style('position', 'absolute') .style('opacity', 1) .style('pointer-events', 'all') @@ -62,12 +63,21 @@ d3.tip = function() { // Returns a tip tip.hide = function() { var nodel = getNodeEl() - nodel + if (nodel.attr("keep_visible") != "true") nodel .style('opacity', 0) .style('pointer-events', 'none') return tip } + // Public - toggle foring or not the tip to remain visible + // + // Returns a tip + tip.toggle_keep_visible = function() { + var nodel = getNodeEl() + nodel.attr("keep_visible", nodel.attr("keep_visible") == "false") + return tip + } + // Public: Proxy attr calls to the d3 tip container. Sets or gets attribute value. // // n - name of the attribute