File tree Expand file tree Collapse file tree 5 files changed +34
-6
lines changed Expand file tree Collapse file tree 5 files changed +34
-6
lines changed Original file line number Diff line number Diff line change 1
1
# History
2
2
----
3
3
4
+ ### 2.3.0 / 2015-07-07
5
+
6
+ ` new ` [ #7 ] ( https://github.com/react-component/tooltip/issues/7 ) support delay prop
7
+
4
8
### 2.2.0 / 2015-06-30
5
9
6
10
- use mask instead of document click
Original file line number Diff line number Diff line change @@ -68,6 +68,12 @@ online example: http://react-component.github.io/tooltip/examples/
68
68
</tr>
69
69
</thead>
70
70
<tbody>
71
+ <tr>
72
+ <td>delay</td>
73
+ <td>number</td>
74
+ <td></td>
75
+ <td>delay time to show or hide, only valid for hover trigger.unit: s.</td>
76
+ </tr>
71
77
<tr>
72
78
<td>overlayStyle</td>
73
79
<td>Object</td>
Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ var Test = React.createClass({
84
84
</ div >
85
85
< div style = { { margin : 100 } } >
86
86
< Tooltip placement = { this . state . placement }
87
+ delay = { 0.1 }
87
88
renderPopupToBody = { this . props . renderPopupToBody }
88
89
trigger = { Object . keys ( this . state . trigger ) }
89
90
onVisibleChange = { this . onVisibleChange }
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " rc-tooltip" ,
3
- "version" : " 2.2.4 " ,
3
+ "version" : " 2.3.0 " ,
4
4
"description" : " tooltip ui component for react" ,
5
5
"keywords" : [
6
6
" react" ,
Original file line number Diff line number Diff line change @@ -85,12 +85,27 @@ class Tooltip extends React.Component {
85
85
}
86
86
}
87
87
88
- show ( ) {
89
- this . setVisible ( true ) ;
88
+ delaySetVisible ( visible , e ) {
89
+ var delay = this . props . delay * 1000 ;
90
+ if ( delay && e && e . type . indexOf ( 'mouse' ) !== - 1 ) {
91
+ if ( this . delayTimer ) {
92
+ clearTimeout ( this . delayTimer ) ;
93
+ }
94
+ this . delayTimer = setTimeout ( ( ) => {
95
+ this . setVisible ( visible ) ;
96
+ this . delayTimer = null ;
97
+ } , delay ) ;
98
+ } else {
99
+ this . setVisible ( visible ) ;
100
+ }
101
+ }
102
+
103
+ show ( e ) {
104
+ this . delaySetVisible ( true , e ) ;
90
105
}
91
106
92
- hide ( ) {
93
- this . setVisible ( false ) ;
107
+ hide ( e ) {
108
+ this . delaySetVisible ( false , e ) ;
94
109
}
95
110
96
111
componentDidMount ( ) {
@@ -157,14 +172,16 @@ Tooltip.propTypes = {
157
172
renderPopupToBody : React . PropTypes . bool ,
158
173
overlay : React . PropTypes . node . isRequired ,
159
174
overlayStyle : React . PropTypes . object ,
160
- wrapStyle : React . PropTypes . object
175
+ wrapStyle : React . PropTypes . object ,
176
+ delay : React . PropTypes . number
161
177
} ;
162
178
163
179
Tooltip . defaultProps = {
164
180
prefixCls : 'rc-tooltip' ,
165
181
renderPopupToBody : true ,
166
182
onVisibleChange : function ( ) {
167
183
} ,
184
+ delay : 0 ,
168
185
overlayStyle : { } ,
169
186
wrapStyle : { } ,
170
187
placement : 'right' ,
You can’t perform that action at this time.
0 commit comments