Skip to content

Commit bacb02b

Browse files
committed
Get real height of parent
1 parent 9aca75a commit bacb02b

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

components/tooltip/_config.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
$tooltip-background: rgba(97,97,97,.9);
2+
$tooltip-margin: 0.5 * $unit;
23
$tooltip-border-radius: .2 * $unit;
34
$tooltip-color: #fff;
45
$tooltip-font-size: $unit;

components/tooltip/index.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ class Tooltip extends React.Component {
2222
const parent = node.parentNode;
2323
if (parent) {
2424
parent.onmouseover = () => {
25+
const parentStyle = parent.currentStyle || window.getComputedStyle(parent);
26+
const offset = parseFloat(parentStyle['margin-bottom']) + parseFloat(parentStyle['padding-bottom']);
2527
const position = parent.getBoundingClientRect();
26-
node.style.top = `${position.top + position.height}px`;
28+
node.style.top = `${position.top + position.height - offset}px`;
2729
node.style.left = `${position.left + parseInt((position.width / 2) - (node.offsetWidth / 2))}px`;
2830
if (!this.state.active) this.setState({ active: true});
2931
};

components/tooltip/style.scss

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
z-index: $z-index-higher;
88
display: inline-block;
99
max-width: $tooltip-max-width;
10-
margin-top: 10px;
1110
padding: $tooltip-padding;
11+
margin: $tooltip-margin 0;
1212
font-size: $font-size-tiny;
1313
font-size: $tooltip-font-size;
1414
font-weight: $font-weight-bold;
@@ -27,10 +27,9 @@
2727
animation-name: tooltip-animation;
2828
}
2929
&.large {
30-
font-size: $font-size-small;
3130
padding: 2 * $tooltip-padding;
31+
font-size: $font-size-small;
3232
}
33-
3433
@keyframes tooltip-animation {
3534
0% {
3635
transform: scale(0);

0 commit comments

Comments
 (0)