@@ -29,12 +29,6 @@ class FlowTipDemo extends Component {
2929 this . updateTargetProperties ( ) ;
3030 }
3131
32- updateTargetProperties ( ) {
33- this . setState ( {
34- target : ReactDOM . findDOMNode ( this . refs . target ) . getBoundingClientRect ( ) ,
35- } ) ;
36- }
37-
3832 handleTargetMove ( ) {
3933 this . updateTargetProperties ( ) ;
4034 }
@@ -45,6 +39,12 @@ class FlowTipDemo extends Component {
4539 } ) ;
4640 }
4741
42+ updateTargetProperties ( ) {
43+ this . setState ( {
44+ target : ReactDOM . findDOMNode ( this . refs . target ) . getBoundingClientRect ( ) ,
45+ } ) ;
46+ }
47+
4848 render ( ) {
4949 const flowtipProperties = {
5050 targetOffset : 10 ,
@@ -99,6 +99,16 @@ class FlowTipDemo extends Component {
9999class FlowTipDemoTarget extends Component {
100100 state = { posX : 0 , posY : 0 , active : true } ;
101101
102+ componentDidMount ( ) {
103+ window . addEventListener ( 'mousemove' , this . handleMouseMove . bind ( this ) ) ;
104+ window . addEventListener ( 'click' , this . handleMouseClick . bind ( this ) ) ;
105+ }
106+
107+ componentWillUnmount ( ) {
108+ window . removeEventListener ( 'mousemove' , this . handleMouseMove . bind ( this ) ) ;
109+ window . removeEventListener ( 'click' , this . handleMouseClick . bind ( this ) ) ;
110+ }
111+
102112 handleMouseMove ( ev ) {
103113 if ( ! this . state . active ) {
104114 return ;
@@ -117,16 +127,6 @@ class FlowTipDemoTarget extends Component {
117127 this . setState ( { active : ! this . state . active } ) ;
118128 }
119129
120- componentDidMount ( ) {
121- window . addEventListener ( 'mousemove' , this . handleMouseMove . bind ( this ) ) ;
122- window . addEventListener ( 'click' , this . handleMouseClick . bind ( this ) ) ;
123- }
124-
125- componentWillUnmount ( ) {
126- window . removeEventListener ( 'mousemove' , this . handleMouseMove . bind ( this ) ) ;
127- window . removeEventListener ( 'click' , this . handleMouseClick . bind ( this ) ) ;
128- }
129-
130130 render ( ) {
131131 const style = {
132132 position : 'absolute' ,
0 commit comments