@@ -13,15 +13,17 @@ class SelectableGroup extends React.Component {
1313 this . state = {
1414 isBoxSelecting : false ,
1515 boxWidth : 0 ,
16- boxHeight : 0 ,
17- mouseDownStarted : false ,
18- mouseMoveStarted : false ,
19- mouseUpStarted : false
16+ boxHeight : 0
2017 }
2118
2219 this . _mouseDownData = null ;
2320 this . _registry = [ ] ;
2421
22+ // Used to prevent actions from firing twice on devices that are both click and touch enabled
23+ this . _mouseDownStarted = false ;
24+ this . _mouseMoveStarted = false ;
25+ this . _mouseUpStarted = false ;
26+
2527 this . _openSelector = this . _openSelector . bind ( this ) ;
2628 this . _mouseDown = this . _mouseDown . bind ( this ) ;
2729 this . _mouseUp = this . _mouseUp . bind ( this ) ;
@@ -73,24 +75,22 @@ class SelectableGroup extends React.Component {
7375 * of the selection box
7476 */
7577 _openSelector ( e ) {
76- if ( this . state . mouseMoveStarted ) return ;
77- this . state . mouseMoveStarted = true ;
78+ if ( this . _mouseMoveStarted ) return ;
79+ this . _mouseMoveStarted = true ;
7880
7981 e = this . _desktopEventCoords ( e ) ;
8082
8183 const w = Math . abs ( this . _mouseDownData . initialW - e . pageX ) ;
8284 const h = Math . abs ( this . _mouseDownData . initialH - e . pageY ) ;
8385
84- var component = this ;
85-
8686 this . setState ( {
8787 isBoxSelecting : true ,
8888 boxWidth : w ,
8989 boxHeight : h ,
9090 boxLeft : Math . min ( e . pageX , this . _mouseDownData . initialW ) ,
9191 boxTop : Math . min ( e . pageY , this . _mouseDownData . initialH )
92- } , function ( ) {
93- component . state . mouseMoveStarted = false ;
92+ } , ( ) => {
93+ this . _mouseMoveStarted = false ;
9494 } ) ;
9595 }
9696
@@ -100,9 +100,9 @@ class SelectableGroup extends React.Component {
100100 * be added, and if so, attach event listeners
101101 */
102102 _mouseDown ( e ) {
103- if ( this . state . mouseDownStarted ) return ;
104- this . state . mouseDownStarted = true ;
105- this . state . mouseUpStarted = false ;
103+ if ( this . _mouseDownStarted ) return ;
104+ this . _mouseDownStarted = true ;
105+ this . _mouseUpStarted = false ;
106106
107107 e = this . _desktopEventCoords ( e ) ;
108108
@@ -151,9 +151,9 @@ class SelectableGroup extends React.Component {
151151 * Called when the user has completed selection
152152 */
153153 _mouseUp ( e ) {
154- if ( this . state . mouseUpStarted ) return ;
155- this . state . mouseUpStarted = true ;
156- this . state . mouseDownStarted = false ;
154+ if ( this . _mouseUpStarted ) return ;
155+ this . _mouseUpStarted = true ;
156+ this . _mouseDownStarted = false ;
157157
158158 ReactDOM . findDOMNode ( this ) . removeEventListener ( 'mousemove' , this . _openSelector ) ;
159159 ReactDOM . findDOMNode ( this ) . removeEventListener ( 'mouseup' , this . _mouseUp ) ;
0 commit comments