File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,9 @@ class ReactHover extends Component {
49
49
} ) )
50
50
} else if ( child . type . name === 'Hover' || child . props . type === 'hover' ) {
51
51
childrenWithProps . push ( React . cloneElement ( child , {
52
- styles : hoverComponentStyle
52
+ styles : hoverComponentStyle ,
53
+ setVisibility : this . setVisibility . bind ( this ) ,
54
+ getCursorPos : this . getCursorPos . bind ( this )
53
55
} ) )
54
56
}
55
57
}
Original file line number Diff line number Diff line change @@ -5,15 +5,37 @@ export default class Hover extends Component {
5
5
static propTypes = {
6
6
type : PropTypes . string ,
7
7
children : PropTypes . object ,
8
- styles : PropTypes . object
9
- }
8
+ styles : PropTypes . object ,
9
+ setVisibility : PropTypes . func ,
10
+ getCursorPos : PropTypes . func
11
+ } ;
10
12
11
13
render ( ) {
12
14
const { styles } = this . props . children . props
13
15
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
+ >
15
22
{ this . props . children . props . children }
16
23
</ div >
17
24
)
18
25
}
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
+ }
19
41
}
You can’t perform that action at this time.
0 commit comments