/
handleVisibleChange.js
47 lines (43 loc) · 1.02 KB
/
handleVisibleChange.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'use strict';
var React = require('react');
var Tooltip = require('rc-tooltip');
require('rc-tooltip/assets/bootstrap.css');
var Test = React.createClass({
getInitialState() {
return {
visible: false
};
},
handleVisibleChange(visible) {
this.setState({
visible: visible
});
},
handleDestroy(){
this.setState({
destroy:true
});
},
render() {
if(this.state.destroy){
return null;
}
return <div >
<div style={{marginTop: 300, marginLeft: 100, marginBottom: 100}}>
<Tooltip
visible={this.state.visible}
animation="zoom"
onVisibleChange={this.handleVisibleChange}
trigger="click"
overlay={<span>i am a tooltip</span>}>
<a href='#' onClick={preventDefault}>trigger</a>
</Tooltip>
</div>
<button onClick={this.handleDestroy}>destroy</button>
</div>;
}
});
function preventDefault(e) {
e.preventDefault();
}
React.render(<Test/>, document.getElementById("__react-content"));