Comparing version 0.6.7 to 0.6.8
{ | ||
"name": "d3-tip", | ||
"version": "0.6.6", | ||
"version": "0.6.8", | ||
"main": "index.js", | ||
@@ -15,4 +15,4 @@ "ignore": [ | ||
"dependencies": { | ||
"d3": "3.4" | ||
"d3": "^3.5.5" | ||
} | ||
} |
32
index.js
@@ -50,3 +50,3 @@ // d3.tip | ||
dir = direction.apply(this, args), | ||
nodel = d3.select(node), | ||
nodel = getNodeEl(), | ||
i = directions.length, | ||
@@ -74,3 +74,3 @@ coords, | ||
tip.hide = function() { | ||
var nodel = d3.select(node) | ||
var nodel = getNodeEl() | ||
nodel.style({ opacity: 0, 'pointer-events': 'none' }) | ||
@@ -88,6 +88,6 @@ return tip | ||
if (arguments.length < 2 && typeof n === 'string') { | ||
return d3.select(node).attr(n) | ||
return getNodeEl().attr(n) | ||
} else { | ||
var args = Array.prototype.slice.call(arguments) | ||
d3.selection.prototype.attr.apply(d3.select(node), args) | ||
d3.selection.prototype.attr.apply(getNodeEl(), args) | ||
} | ||
@@ -106,6 +106,6 @@ | ||
if (arguments.length < 2 && typeof n === 'string') { | ||
return d3.select(node).style(n) | ||
return getNodeEl().style(n) | ||
} else { | ||
var args = Array.prototype.slice.call(arguments) | ||
d3.selection.prototype.style.apply(d3.select(node), args) | ||
d3.selection.prototype.style.apply(getNodeEl(), args) | ||
} | ||
@@ -153,2 +153,13 @@ | ||
// Public: destroys the tooltip and removes it from the DOM | ||
// | ||
// Returns a tip | ||
tip.destroy = function() { | ||
if(node) { | ||
getNodeEl().remove(); | ||
node = null; | ||
} | ||
return tip; | ||
} | ||
function d3_tip_direction() { return 'n' } | ||
@@ -256,2 +267,11 @@ function d3_tip_offset() { return [0, 0] } | ||
function getNodeEl() { | ||
if(node === null) { | ||
node = initNode(); | ||
// re-add node to DOM | ||
document.body.appendChild(node); | ||
}; | ||
return d3.select(node); | ||
} | ||
// Private - gets the screen coordinates of a shape | ||
@@ -258,0 +278,0 @@ // |
{ | ||
"name": "d3-tip", | ||
"version": "0.6.7", | ||
"version": "0.6.8", | ||
"description": "Tooltips for d3 svg visualizations", | ||
@@ -22,3 +22,2 @@ "author": "Justin Palmer <justin@labratrevenge.com> (http://labratrevenge.com/d3-tip)", | ||
], | ||
"author": "Justin Palmer", | ||
"license": "MIT", | ||
@@ -28,3 +27,6 @@ "bugs": { | ||
}, | ||
"homepage": "https://github.com/Caged/d3-tip" | ||
"homepage": "https://github.com/Caged/d3-tip", | ||
"dependencies": { | ||
"d3": "^3.5.5" | ||
} | ||
} |
51170
348
1