-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tooltip.js
50 lines (42 loc) · 1.15 KB
/
Tooltip.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"use strict";
var React = require("react");
var d3 = require("d3");
var Tooltip = React.createClass({
displayName: "Tooltip",
propTypes: {
top: React.PropTypes.number.isRequired,
left: React.PropTypes.number.isRequired,
html: React.PropTypes.node,
translate: React.PropTypes.number
},
getDefaultProps: function getDefaultProps() {
return {
top: 150,
left: 100,
html: "",
translate: 50
};
},
render: function render() {
var _props = this.props;
var top = _props.top;
var left = _props.left;
var hidden = _props.hidden;
var html = _props.html;
var translate = _props.translate;
var style = {
display: hidden ? "none" : "block",
position: "fixed",
top: top,
left: left,
transform: "translate(-" + translate + "%, 0)",
pointerEvents: "none"
};
return React.createElement(
"div",
{ className: "tooltip", style: style },
html
);
}
});
module.exports = Tooltip;