Skip to content

Commit 6229aff

Browse files
authored
Merge pull request #30 from bucketsec/bugfix/blinking_fix
Fixed blinking issue
2 parents 6652c57 + c8829da commit 6229aff

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

src/ReactHover.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ class ReactHover extends Component {
4949
}))
5050
} else if (child.type.name === 'Hover' || child.props.type === 'hover') {
5151
childrenWithProps.push(React.cloneElement(child, {
52-
styles: hoverComponentStyle
52+
styles: hoverComponentStyle,
53+
setVisibility: this.setVisibility.bind(this),
54+
getCursorPos: this.getCursorPos.bind(this)
5355
}))
5456
}
5557
}

src/lib/Hover.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,37 @@ export default class Hover extends Component {
55
static propTypes = {
66
type: PropTypes.string,
77
children: PropTypes.object,
8-
styles: PropTypes.object
9-
}
8+
styles: PropTypes.object,
9+
setVisibility: PropTypes.func,
10+
getCursorPos: PropTypes.func
11+
};
1012

1113
render () {
1214
const { styles } = this.props.children.props
1315
return (
14-
<div style={styles}>
16+
<div
17+
onMouseOver={this.onMouseOver.bind(this)}
18+
onMouseOut={this.onMouseOut.bind(this)}
19+
onMouseMove={this.onMouseMove.bind(this)}
20+
style={styles}
21+
>
1522
{this.props.children.props.children}
1623
</div>
1724
)
1825
}
26+
27+
onMouseOver () {
28+
const { setVisibility } = this.props.children.props
29+
setVisibility(true)
30+
}
31+
32+
onMouseOut () {
33+
const { setVisibility } = this.props.children.props
34+
setVisibility(false)
35+
}
36+
37+
onMouseMove (e) {
38+
const { getCursorPos } = this.props.children.props
39+
getCursorPos(e)
40+
}
1941
}

0 commit comments

Comments
 (0)