diff --git a/src/index.js b/src/index.js index 597e4d43..6877ddda 100644 --- a/src/index.js +++ b/src/index.js @@ -280,14 +280,21 @@ class ReactTooltip extends React.Component { // To prevent previously created timers from triggering this.clearTimer() + // Make sure the correct place is set + let node = ReactDOM.findDOMNode(this) + let desiredPlace = e.currentTarget.getAttribute('data-place') || this.props.place || 'top' + let effect = switchToSolid && 'solid' || this.getEffect(e.currentTarget) + let offset = e.currentTarget.getAttribute('data-offset') || this.props.offset || {} + let result = getPosition(e, e.currentTarget, ReactDOM.findDOMNode(this), desiredPlace, desiredPlace, effect, offset) + this.setState({ originTooltip: originTooltip, isMultiline: isMultiline, - desiredPlace: e.currentTarget.getAttribute('data-place') || this.props.place || 'top', - place: e.currentTarget.getAttribute('data-place') || this.props.place || 'top', + desiredPlace: desiredPlace, + place: result.isNewState ? result.newState.place : desiredPlace, type: e.currentTarget.getAttribute('data-type') || this.props.type || 'dark', - effect: switchToSolid && 'solid' || this.getEffect(e.currentTarget), - offset: e.currentTarget.getAttribute('data-offset') || this.props.offset || {}, + effect: effect, + offset: offset, html: e.currentTarget.getAttribute('data-html') ? e.currentTarget.getAttribute('data-html') === 'true' : (this.props.html || false), @@ -485,4 +492,4 @@ class ReactTooltip extends React.Component { } /* export default not fit for standalone, it will exports {default:...} */ -module.exports = ReactTooltip +module.exports = ReactTooltip \ No newline at end of file