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

Use node parent when calculating offset #195

Merged
merged 1 commit into from
Sep 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

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