Skip to content

Commit 5d5158a

Browse files
committed
Remove countTransform because the way of transform calculation is changed
1 parent 88edd43 commit 5d5158a

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class | data-class | String | | extra custom class, can use !important to
6262
delayShow | data-delay-show | Number | | `<p data-tip="tooltip" data-delay-show='1000'></p>` or `<ReactTooltip delayShow={1000} />`
6363
border | data-border | Bool | true, false | Add one pixel white border
6464
getContent | null | Func or Array | () => {}, [() => {}, Interval] | Generate the tip content dynamically
65-
countTransform | data-count-transform | Bool | True, False | Tell tooltip if it needs to count parents' transform into position calculation, the default is true, but it should be set to false when using with react-list
6665
afterShow | null | Func | () => {} | Function that will be called after tooltip show
6766
afterHide | null | Func | () => {} | Function that will be called after tooltip hide
6867
disable | data-tip-disable | Bool | true, false | Disable the tooltip behaviour, default is false

example/src/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const Test = React.createClass({
4545
<div>
4646
<section className='tooltip-example'>
4747
<h4 className='title'>React Tooltip</h4>
48-
<div style={{marginTop: 40, transform: "translateY(-20px)"}} className='demonstration'>
48+
<div className='demonstration'>
4949
<a data-for='main' data-tip="Hello<br />multiline<br />tooltip">
5050
◕‿‿◕
5151
</a>
@@ -83,9 +83,7 @@ const Test = React.createClass({
8383
</div>
8484
</pre>
8585
</div>
86-
<div style={{transform: "translateY(40px)"}}>
87-
<ReactTooltip id='main' place={place} type={type} effect={effect} multiline={true}/>
88-
</div>
86+
<ReactTooltip id='main' place={place} type={type} effect={effect} multiline={true}/>
8987
</section>
9088
<section className="advance">
9189
<div className="section">
@@ -253,4 +251,4 @@ const Test = React.createClass({
253251
}
254252
})
255253

256-
render(<Test />, document.getElementById('main'))
254+
render(<Test />, document.getElementById('main'))

src/index.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class ReactTooltip extends Component {
4040
isCapture: PropTypes.bool,
4141
globalEventOff: PropTypes.string,
4242
getContent: PropTypes.any,
43-
countTransform: PropTypes.bool,
4443
afterShow: PropTypes.func,
4544
afterHide: PropTypes.func,
4645
disable: PropTypes.bool,
@@ -261,10 +260,7 @@ class ReactTooltip extends Component {
261260
border: e.currentTarget.getAttribute('data-border')
262261
? e.currentTarget.getAttribute('data-border') === 'true'
263262
: (this.props.border || false),
264-
extraClass: e.currentTarget.getAttribute('data-class') || this.props.class || '',
265-
countTransform: e.currentTarget.getAttribute('data-count-transform')
266-
? e.currentTarget.getAttribute('data-count-transform') === 'true'
267-
: (this.props.countTransform != null ? this.props.countTransform : true)
263+
extraClass: e.currentTarget.getAttribute('data-class') || this.props.class || ''
268264
}, () => {
269265
if (scrollHide) this.addScrollListener(e)
270266
this.updateTooltip(e)
@@ -362,10 +358,10 @@ class ReactTooltip extends Component {
362358

363359
// Calculation the position
364360
updatePosition () {
365-
const {currentEvent, currentTarget, place, effect, offset, countTransform} = this.state
361+
const {currentEvent, currentTarget, place, effect, offset} = this.state
366362
const node = ReactDOM.findDOMNode(this)
367363

368-
const result = getPosition(currentEvent, currentTarget, node, place, effect, offset, countTransform)
364+
const result = getPosition(currentEvent, currentTarget, node, place, effect, offset)
369365

370366
if (result.isNewState) {
371367
// Switch to reverse placement

src/utils/getPosition.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* - `newState` {Object}
1515
* - `position` {OBject} {left: {Number}, top: {Number}}
1616
*/
17-
export default function (e, target, node, place, effect, offset, countTransform) {
17+
export default function (e, target, node, place, effect, offset) {
1818
const tipWidth = node.clientWidth
1919
const tipHeight = node.clientHeight
2020
const {mouseX, mouseY} = getCurrentOffset(e, target, effect)
@@ -24,7 +24,7 @@ export default function (e, target, node, place, effect, offset, countTransform)
2424
const windowWidth = window.innerWidth
2525
const windowHeight = window.innerHeight
2626

27-
const {parentTop, parentLeft} = countTransform && getParent(node, countTransform) || {parentTop: 0, parentLeft: 0}
27+
const {parentTop, parentLeft} = getParent(node)
2828

2929
// Get the edge offset of the tooltip
3030
const getTipOffsetLeft = (place) => {

0 commit comments

Comments
 (0)