@@ -462,6 +462,25 @@ var ReactTooltip = function (_Component) {
462462 var defaultLeftX = targetLeft - tipWidth - 6 ;
463463 var defaultRightX = targetLeft + targetWidth + 6 ;
464464
465+ var parentTop = 0 ;
466+ var parentLeft = 0 ;
467+
468+ if ( this . props . checkParentTransform ) {
469+ var currentParent = currentTarget . parentElement ;
470+
471+ while ( currentParent ) {
472+ if ( currentParent . style . transform . length > 0 ) {
473+ break ;
474+ }
475+ currentParent = currentParent . parentElement ;
476+ }
477+
478+ if ( currentParent ) {
479+ parentTop = currentParent . getBoundingClientRect ( ) . top ;
480+ parentLeft = currentParent . getBoundingClientRect ( ) . left ;
481+ }
482+ }
483+
465484 var outsideTop = function outsideTop ( ) {
466485 return defaultTopY - 10 < 0 ;
467486 } ;
@@ -523,17 +542,17 @@ var ReactTooltip = function (_Component) {
523542 } ;
524543
525544 if ( place === 'top' ) {
526- x = targetLeft - tipWidth / 2 + targetWidth / 2 ;
527- y = getTopPositionY ( ) ;
545+ x = targetLeft - tipWidth / 2 + targetWidth / 2 - parentLeft ;
546+ y = getTopPositionY ( ) - parentTop ;
528547 } else if ( place === 'bottom' ) {
529- x = targetLeft - tipWidth / 2 + targetWidth / 2 ;
530- y = getBottomPositionY ( ) ;
548+ x = targetLeft - tipWidth / 2 + targetWidth / 2 - parentLeft ;
549+ y = getBottomPositionY ( ) - parentTop ;
531550 } else if ( place === 'left' ) {
532- x = getLeftPositionX ( ) ;
533- y = targetTop + targetHeight / 2 - tipHeight / 2 ;
551+ x = getLeftPositionX ( ) - parentLeft ;
552+ y = targetTop + targetHeight / 2 - tipHeight / 2 - parentTop ;
534553 } else if ( place === 'right' ) {
535- x = getRightPositionX ( ) ;
536- y = targetTop + targetHeight / 2 - tipHeight / 2 ;
554+ x = getRightPositionX ( ) - parentLeft ;
555+ y = targetTop + targetHeight / 2 - tipHeight / 2 - parentTop ;
537556 }
538557
539558 return { x : x , y : y } ;
0 commit comments