Skip to content

Commit

Permalink
Merge pull request #195 from iamdoron/master
Browse files Browse the repository at this point in the history
Use node parent when calculating offset
  • Loading branch information
wwayne authored Sep 29, 2016
2 parents 9e3722c + ae8b7ae commit 88edd43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions example/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const Test = React.createClass({
<div>
<section className='tooltip-example'>
<h4 className='title'>React Tooltip</h4>
<div className='demonstration'>
<div style={{marginTop: 40, transform: "translateY(-20px)"}} className='demonstration'>
<a data-for='main' data-tip="Hello<br />multiline<br />tooltip">
◕‿‿◕
</a>
Expand Down Expand Up @@ -83,7 +83,9 @@ const Test = React.createClass({
</div>
</pre>
</div>
<ReactTooltip id='main' place={place} type={type} effect={effect} multiline={true}/>
<div style={{transform: "translateY(40px)"}}>
<ReactTooltip id='main' place={place} type={type} effect={effect} multiline={true}/>
</div>
</section>
<section className="advance">
<div className="section">
Expand Down Expand Up @@ -251,4 +253,4 @@ const Test = React.createClass({
}
})

render(<Test />, document.getElementById('main'))
render(<Test />, document.getElementById('main'))
2 changes: 1 addition & 1 deletion src/utils/getPosition.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function (e, target, node, place, effect, offset, countTransform)
const windowWidth = window.innerWidth
const windowHeight = window.innerHeight

const {parentTop, parentLeft} = countTransform && getParent(target, countTransform) || {parentTop: 0, parentLeft: 0}
const {parentTop, parentLeft} = countTransform && getParent(node, countTransform) || {parentTop: 0, parentLeft: 0}

// Get the edge offset of the tooltip
const getTipOffsetLeft = (place) => {
Expand Down

0 comments on commit 88edd43

Please sign in to comment.