@@ -357,6 +357,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
357
357
_this . mount = true ;
358
358
_this . delayShowLoop = null ;
359
359
_this . delayHideLoop = null ;
360
+ _this . intervalUpdateContent = null ;
360
361
return _this ;
361
362
}
362
363
@@ -372,8 +373,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
372
373
value : function componentWillUnmount ( ) {
373
374
this . mount = false ;
374
375
375
- clearTimeout ( this . delayShowLoop ) ;
376
- clearTimeout ( this . delayHideLoop ) ;
376
+ this . clearTimer ( ) ;
377
377
378
378
this . unbindListener ( ) ;
379
379
this . removeScrollListener ( ) ;
@@ -492,10 +492,21 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
492
492
var _props3 = this . props ;
493
493
var children = _props3 . children ;
494
494
var multiline = _props3 . multiline ;
495
+ var getContent = _props3 . getContent ;
495
496
496
497
var originTooltip = e . currentTarget . getAttribute ( 'data-tip' ) ;
497
498
var isMultiline = e . currentTarget . getAttribute ( 'data-multiline' ) || multiline || false ;
498
- var placeholder = ( 0 , _getTipContent2 . default ) ( originTooltip , children , isMultiline ) ;
499
+
500
+ var content = children ;
501
+ if ( getContent ) {
502
+ if ( Array . isArray ( getContent ) ) {
503
+ content = getContent [ 0 ] && getContent [ 0 ] ( ) ;
504
+ } else {
505
+ content = getContent ( ) ;
506
+ }
507
+ }
508
+
509
+ var placeholder = ( 0 , _getTipContent2 . default ) ( originTooltip , content , isMultiline ) ;
499
510
500
511
this . setState ( {
501
512
placeholder : placeholder ,
@@ -511,6 +522,17 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
511
522
} , function ( ) {
512
523
_this4 . addScrollListener ( e ) ;
513
524
_this4 . updateTooltip ( e ) ;
525
+
526
+ if ( getContent && Array . isArray ( getContent ) ) {
527
+ _this4 . intervalUpdateContent = setInterval ( function ( ) {
528
+ var getContent = _this4 . props . getContent ;
529
+
530
+ var placeholder = ( 0 , _getTipContent2 . default ) ( originTooltip , getContent [ 0 ] ( ) , isMultiline ) ;
531
+ _this4 . setState ( {
532
+ placeholder : placeholder
533
+ } ) ;
534
+ } , getContent [ 1 ] ) ;
535
+ }
514
536
} ) ;
515
537
}
516
538
@@ -560,8 +582,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
560
582
561
583
if ( ! this . mount ) return ;
562
584
563
- clearTimeout ( this . delayShowLoop ) ;
564
- clearTimeout ( this . delayHideLoop ) ;
585
+ this . clearTimer ( ) ;
565
586
this . delayHideLoop = setTimeout ( function ( ) {
566
587
_this6 . setState ( {
567
588
show : false
@@ -631,6 +652,18 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
631
652
document . getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( tag ) ;
632
653
}
633
654
}
655
+
656
+ /**
657
+ * CLear all kinds of timeout of interval
658
+ */
659
+
660
+ } , {
661
+ key : 'clearTimer' ,
662
+ value : function clearTimer ( ) {
663
+ clearTimeout ( this . delayShowLoop ) ;
664
+ clearTimeout ( this . delayHideLoop ) ;
665
+ clearInterval ( this . intervalUpdateContent ) ;
666
+ }
634
667
} , {
635
668
key : 'render' ,
636
669
value : function render ( ) {
@@ -674,7 +707,8 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
674
707
eventOff : _react . PropTypes . string ,
675
708
watchWindow : _react . PropTypes . bool ,
676
709
isCapture : _react . PropTypes . bool ,
677
- globalEventOff : _react . PropTypes . string
710
+ globalEventOff : _react . PropTypes . string ,
711
+ getContent : _react . PropTypes . any
678
712
} , _temp ) ) || _class ) || _class ) || _class ) || _class ;
679
713
680
714
/* export default not fit for standalone, it will exports {default:...} */
0 commit comments