@@ -1835,7 +1835,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
18351835 var isMyElement = targetArray . some ( function ( ele ) {
18361836 return ele === e . currentTarget ;
18371837 } ) ;
1838- if ( ! isMyElement || this . state . show ) return ;
1838+ if ( ! isMyElement ) return ;
18391839 }
18401840 // Get the tooltip content
18411841 // calculate in this phrase so that tip width height can be detected
@@ -1888,6 +1888,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
18881888 _this5 . setState ( {
18891889 isEmptyTip : isEmptyTip
18901890 } ) ;
1891+ _this5 . updatePosition ( ) ;
18911892 }
18921893 } , getContent [ 1 ] ) ;
18931894 }
@@ -2172,14 +2173,19 @@ Object.defineProperty(exports, "__esModule", {
21722173} ) ;
21732174
21742175exports . default = function ( e , target , node , place , desiredPlace , effect , offset ) {
2175- var tipWidth = node . clientWidth ;
2176- var tipHeight = node . clientHeight ;
2176+ var _getDimensions = getDimensions ( node ) ,
2177+ tipWidth = _getDimensions . width ,
2178+ tipHeight = _getDimensions . height ;
2179+
2180+ var _getDimensions2 = getDimensions ( target ) ,
2181+ targetWidth = _getDimensions2 . width ,
2182+ targetHeight = _getDimensions2 . height ;
21772183
21782184 var _getCurrentOffset = getCurrentOffset ( e , target , effect ) ,
21792185 mouseX = _getCurrentOffset . mouseX ,
21802186 mouseY = _getCurrentOffset . mouseY ;
21812187
2182- var defaultOffset = getDefaultPosition ( effect , target . clientWidth , target . clientHeight , tipWidth , tipHeight ) ;
2188+ var defaultOffset = getDefaultPosition ( effect , targetWidth , targetHeight , tipWidth , tipHeight ) ;
21832189
21842190 var _calculateOffset = calculateOffset ( offset ) ,
21852191 extraOffset_X = _calculateOffset . extraOffset_X ,
@@ -2361,28 +2367,18 @@ exports.default = function (e, target, node, place, desiredPlace, effect, offset
23612367 } ;
23622368} ;
23632369
2364- // Get current mouse offset
2365- var getCurrentOffset = function getCurrentOffset ( e , currentTarget , effect ) {
2366- var boundingClientRect = currentTarget . getBoundingClientRect ( ) ;
2367- var targetTop = boundingClientRect . top ;
2368- var targetLeft = boundingClientRect . left ;
2369- var targetWidth = currentTarget . clientWidth ;
2370- var targetHeight = currentTarget . clientHeight ;
2370+ var getDimensions = function getDimensions ( node ) {
2371+ var _node$getBoundingClie = node . getBoundingClientRect ( ) ,
2372+ height = _node$getBoundingClie . height ,
2373+ width = _node$getBoundingClie . width ;
23712374
2372- if ( effect === 'float' ) {
2373- return {
2374- mouseX : e . clientX ,
2375- mouseY : e . clientY
2376- } ;
2377- }
23782375 return {
2379- mouseX : targetLeft + targetWidth / 2 ,
2380- mouseY : targetTop + targetHeight / 2
2376+ height : parseInt ( height , 10 ) ,
2377+ width : parseInt ( width , 10 )
23812378 } ;
23822379} ;
23832380
2384- // List all possibility of tooltip final offset
2385- // This is useful in judging if it is necessary for tooltip to switch position when out of window
2381+ // Get current mouse offset
23862382/**
23872383 * Calculate the position of tooltip
23882384 *
@@ -2399,6 +2395,29 @@ var getCurrentOffset = function getCurrentOffset(e, currentTarget, effect) {
23992395 * - `newState` {Object}
24002396 * - `position` {OBject} {left: {Number}, top: {Number}}
24012397 */
2398+ var getCurrentOffset = function getCurrentOffset ( e , currentTarget , effect ) {
2399+ var boundingClientRect = currentTarget . getBoundingClientRect ( ) ;
2400+ var targetTop = boundingClientRect . top ;
2401+ var targetLeft = boundingClientRect . left ;
2402+
2403+ var _getDimensions3 = getDimensions ( currentTarget ) ,
2404+ targetWidth = _getDimensions3 . width ,
2405+ targetHeight = _getDimensions3 . height ;
2406+
2407+ if ( effect === 'float' ) {
2408+ return {
2409+ mouseX : e . clientX ,
2410+ mouseY : e . clientY
2411+ } ;
2412+ }
2413+ return {
2414+ mouseX : targetLeft + targetWidth / 2 ,
2415+ mouseY : targetTop + targetHeight / 2
2416+ } ;
2417+ } ;
2418+
2419+ // List all possibility of tooltip final offset
2420+ // This is useful in judging if it is necessary for tooltip to switch position when out of window
24022421var getDefaultPosition = function getDefaultPosition ( effect , targetWidth , targetHeight , tipWidth , tipHeight ) {
24032422 var top = void 0 ;
24042423 var right = void 0 ;
0 commit comments