Skip to content

Commit

Permalink
Merge pull request #131 from pokidovea/lazy_content
Browse files Browse the repository at this point in the history
Add possibility to recalculate content on show tooltip
  • Loading branch information
wwayne committed Jul 11, 2016
2 parents 8bc4bfe + 5e058dd commit 7f6b50f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/index.js
Expand Up @@ -37,7 +37,8 @@ class ReactTooltip extends Component {
eventOff: PropTypes.string,
watchWindow: PropTypes.bool,
isCapture: PropTypes.bool,
globalEventOff: PropTypes.string
globalEventOff: PropTypes.string,
getContent: PropTypes.func
}

constructor (props) {
Expand Down Expand Up @@ -165,10 +166,18 @@ class ReactTooltip extends Component {
showTooltip (e) {
// Get the tooltip content
// calculate in this phrase so that tip width height can be detected
const {children, multiline} = this.props
const {children, multiline, getContent} = this.props
const originTooltip = e.currentTarget.getAttribute('data-tip')
const isMultiline = e.currentTarget.getAttribute('data-multiline') || multiline || false
const placeholder = getTipContent(originTooltip, children, isMultiline)

let content
if (children) {
content = children
} else if (getContent) {
content = getContent()
}

const placeholder = getTipContent(originTooltip, content, isMultiline)

this.setState({
placeholder,
Expand Down

0 comments on commit 7f6b50f

Please sign in to comment.