File tree 1 file changed +8
-3
lines changed 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {
15
15
} from '../reducers/color-picker' ;
16
16
17
17
const colorPickerRadius = 20 ;
18
+ const dragThreshold = 3 ; // Same as the block drag threshold
18
19
19
20
class Stage extends React . Component {
20
21
constructor ( props ) {
@@ -149,9 +150,13 @@ class Stage extends React.Component {
149
150
this . pickX = mousePosition [ 0 ] ;
150
151
this . pickY = mousePosition [ 1 ] ;
151
152
152
- if ( this . state . mouseDownTimeoutId !== null ) {
153
- this . cancelMouseDownTimeout ( ) ;
154
- if ( this . state . mouseDown && ! this . state . isDragging ) {
153
+ if ( this . state . mouseDown && ! this . state . isDragging ) {
154
+ const distanceFromMouseDown = Math . sqrt (
155
+ Math . pow ( mousePosition [ 0 ] - this . state . mouseDownPosition [ 0 ] , 2 ) +
156
+ Math . pow ( mousePosition [ 1 ] - this . state . mouseDownPosition [ 1 ] , 2 )
157
+ ) ;
158
+ if ( distanceFromMouseDown > dragThreshold ) {
159
+ this . cancelMouseDownTimeout ( ) ;
155
160
this . onStartDrag ( ...this . state . mouseDownPosition ) ;
156
161
}
157
162
}
You can’t perform that action at this time.
0 commit comments