Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to recalculate content on show tooltip #131

Merged
merged 1 commit into from Jul 11, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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