From 8bfbfc960bdc62e716fd2d3f0ec6bb8c54edf01e Mon Sep 17 00:00:00 2001 From: austil Date: Tue, 15 May 2018 17:57:48 +0200 Subject: [PATCH] feat: getContent(dataTip) --- README.md | 2 +- example/src/index.js | 21 +++++++++++++++++++++ src/index.js | 4 ++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5522544c1..f12028b0b 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ className | data-class | String | | extra custom class, can use !importan delayShow | data-delay-show | Number | | `

` or `` insecure | null | Bool | true, false | Whether to inject the style header into the page dynamically (violates CSP style-src but is a convenient default) border | data-border | Bool | true, false | Add one pixel white border - getContent | null | Func or Array | () => {}, [() => {}, Interval] | Generate the tip content dynamically + getContent | null | Func or Array | (dataTip) => {}, [(dataTip) => {}, Interval] | Generate the tip content dynamically afterShow | null | Func | () => {} | Function that will be called after tooltip show afterHide | null | Func | () => {} | Function that will be called after tooltip hide disable | data-tip-disable | Bool | true, false | Disable the tooltip behaviour, default is false diff --git a/example/src/index.js b/example/src/index.js index 4f9cbb3a9..9c211fed8 100755 --- a/example/src/index.js +++ b/example/src/index.js @@ -248,6 +248,27 @@ class Test extends React.Component { +
+

Compute or enrich tip content

+

+
+
+ (❂‿❂) +
+
+ (❂‿❂) +
+ `This little buddy is ${dataTip}`}/> +
+
+
+              
+

{"(❂‿❂)\n" + + "(❂‿❂)\n" + + " `This little buddy is ${dataTip}`}/>"}

+
+
+

Test Scrolling

diff --git a/src/index.js b/src/index.js index e6896772d..254ca4901 100644 --- a/src/index.js +++ b/src/index.js @@ -237,9 +237,9 @@ class ReactTooltip extends React.Component { let content if (getContent) { if (Array.isArray(getContent)) { - content = getContent[0] && getContent[0]() + content = getContent[0] && getContent[0](this.state.originTooltip) } else { - content = getContent() + content = getContent(this.state.originTooltip) } }