@@ -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' ;
0 commit comments