@@ -462,6 +462,25 @@ var ReactTooltip = function (_Component) {
462
462
var defaultLeftX = targetLeft - tipWidth - 6 ;
463
463
var defaultRightX = targetLeft + targetWidth + 6 ;
464
464
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
+
465
484
var outsideTop = function outsideTop ( ) {
466
485
return defaultTopY - 10 < 0 ;
467
486
} ;
@@ -523,17 +542,17 @@ var ReactTooltip = function (_Component) {
523
542
} ;
524
543
525
544
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 ;
528
547
} 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 ;
531
550
} 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 ;
534
553
} 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 ;
537
556
}
538
557
539
558
return { x : x , y : y } ;
0 commit comments