@@ -357,6 +357,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
357357 _this . mount = true ;
358358 _this . delayShowLoop = null ;
359359 _this . delayHideLoop = null ;
360+ _this . intervalUpdateContent = null ;
360361 return _this ;
361362 }
362363
@@ -372,8 +373,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
372373 value : function componentWillUnmount ( ) {
373374 this . mount = false ;
374375
375- clearTimeout ( this . delayShowLoop ) ;
376- clearTimeout ( this . delayHideLoop ) ;
376+ this . clearTimer ( ) ;
377377
378378 this . unbindListener ( ) ;
379379 this . removeScrollListener ( ) ;
@@ -492,10 +492,21 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
492492 var _props3 = this . props ;
493493 var children = _props3 . children ;
494494 var multiline = _props3 . multiline ;
495+ var getContent = _props3 . getContent ;
495496
496497 var originTooltip = e . currentTarget . getAttribute ( 'data-tip' ) ;
497498 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 ) ;
499510
500511 this . setState ( {
501512 placeholder : placeholder ,
@@ -511,6 +522,17 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
511522 } , function ( ) {
512523 _this4 . addScrollListener ( e ) ;
513524 _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+ }
514536 } ) ;
515537 }
516538
@@ -560,8 +582,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
560582
561583 if ( ! this . mount ) return ;
562584
563- clearTimeout ( this . delayShowLoop ) ;
564- clearTimeout ( this . delayHideLoop ) ;
585+ this . clearTimer ( ) ;
565586 this . delayHideLoop = setTimeout ( function ( ) {
566587 _this6 . setState ( {
567588 show : false
@@ -631,6 +652,18 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
631652 document . getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( tag ) ;
632653 }
633654 }
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+ }
634667 } , {
635668 key : 'render' ,
636669 value : function render ( ) {
@@ -674,7 +707,8 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
674707 eventOff : _react . PropTypes . string ,
675708 watchWindow : _react . PropTypes . bool ,
676709 isCapture : _react . PropTypes . bool ,
677- globalEventOff : _react . PropTypes . string
710+ globalEventOff : _react . PropTypes . string ,
711+ getContent : _react . PropTypes . any
678712} , _temp ) ) || _class ) || _class ) || _class ) || _class ;
679713
680714/* export default not fit for standalone, it will exports {default:...} */
0 commit comments