Skip to content

Commit 47882f4

Browse files
committed
3.0.11
1 parent db471ef commit 47882f4

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## Change Log
22

3+
### 3.0.11 (2016/07/14 06:57 +00:00)
4+
- [#135](https://github.com/wwayne/react-tooltip/pull/135) Transform 3d (@wwayne)
5+
36
### 3.0.9 (2016/07/12 00:23 +00:00)
47
- [#132](https://github.com/wwayne/react-tooltip/pull/132) Make getContent to support dynamical generate content while hover (@wwayne)
58
- [#131](https://github.com/wwayne/react-tooltip/pull/131) Add possibility to recalculate content on show tooltip (@pokidovea)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-tooltip",
3-
"version": "3.0.10",
3+
"version": "3.0.11",
44
"description": "react tooltip component",
55
"main": "dist/index.js",
66
"scripts": {

standalone/react-tooltip.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,13 @@ exports.default = function (e, target, node, place, effect, offset) {
752752
var windowWidth = window.innerWidth;
753753
var windowHeight = window.innerHeight;
754754

755+
var _getParent = getParent(target);
756+
757+
var parentTop = _getParent.parentTop;
758+
var parentLeft = _getParent.parentLeft;
759+
755760
// Get the edge offset of the tooltip
761+
756762
var getTipOffsetLeft = function getTipOffsetLeft(place) {
757763
var offset_X = defaultOffset[place].l;
758764
return mouseX + offset_X + extraOffset_X;
@@ -889,8 +895,8 @@ exports.default = function (e, target, node, place, effect, offset) {
889895
return {
890896
isNewState: false,
891897
position: {
892-
left: getTipOffsetLeft(place),
893-
top: getTipOffsetTop(place)
898+
left: getTipOffsetLeft(place) - parentLeft,
899+
top: getTipOffsetTop(place) - parentTop
894900
}
895901
};
896902
};
@@ -938,8 +944,9 @@ var getDefaultPosition = function getDefaultPosition(effect, targetWidth, target
938944
var right = void 0;
939945
var bottom = void 0;
940946
var left = void 0;
941-
var disToMouse = 8;
947+
var disToMouse = 3;
942948
var triangleHeight = 2;
949+
var cursorHeight = 12; // Optimize for float bottom only, cause the cursor will hide the tooltip
943950

944951
if (effect === 'float') {
945952
top = {
@@ -951,8 +958,8 @@ var getDefaultPosition = function getDefaultPosition(effect, targetWidth, target
951958
bottom = {
952959
l: -(tipWidth / 2),
953960
r: tipWidth / 2,
954-
t: disToMouse,
955-
b: tipHeight + disToMouse + triangleHeight
961+
t: disToMouse + cursorHeight,
962+
b: tipHeight + disToMouse + triangleHeight + cursorHeight
956963
};
957964
left = {
958965
l: -(tipWidth + disToMouse + triangleHeight),
@@ -1019,6 +1026,20 @@ var calculateOffset = function calculateOffset(offset) {
10191026
return { extraOffset_X: extraOffset_X, extraOffset_Y: extraOffset_Y };
10201027
};
10211028

1029+
// Get the offset of the parent elements
1030+
var getParent = function getParent(currentTarget) {
1031+
var currentParent = currentTarget.parentElement;
1032+
while (currentParent) {
1033+
if (currentParent.style.transform.length > 0) break;
1034+
currentParent = currentParent.parentElement;
1035+
}
1036+
1037+
var parentTop = currentParent && currentParent.getBoundingClientRect().top || 0;
1038+
var parentLeft = currentParent && currentParent.getBoundingClientRect().left || 0;
1039+
1040+
return { parentTop: parentTop, parentLeft: parentLeft };
1041+
};
1042+
10221043
},{}],10:[function(require,module,exports){
10231044
(function (global){
10241045
'use strict';

standalone/react-tooltip.min.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)