From a163228162848b456b966800d84621515c56023b Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Fri, 9 Feb 2018 10:43:20 -0500 Subject: [PATCH] Apply a drag threshold to make clicking sprites easier. Use the same drag threshold as from the blocks. It may need to be dialed in further, but testing will be needed. --- src/containers/stage.jsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/containers/stage.jsx b/src/containers/stage.jsx index 1f4e62ed586..5095f86dd07 100644 --- a/src/containers/stage.jsx +++ b/src/containers/stage.jsx @@ -15,6 +15,7 @@ import { } from '../reducers/color-picker'; const colorPickerRadius = 20; +const dragThreshold = 3; // Same as the block drag threshold class Stage extends React.Component { constructor (props) { @@ -149,9 +150,13 @@ class Stage extends React.Component { this.pickX = mousePosition[0]; this.pickY = mousePosition[1]; - if (this.state.mouseDownTimeoutId !== null) { - this.cancelMouseDownTimeout(); - if (this.state.mouseDown && !this.state.isDragging) { + if (this.state.mouseDown && !this.state.isDragging) { + const distanceFromMouseDown = Math.sqrt( + Math.pow(mousePosition[0] - this.state.mouseDownPosition[0], 2) + + Math.pow(mousePosition[1] - this.state.mouseDownPosition[1], 2) + ); + if (distanceFromMouseDown > dragThreshold) { + this.cancelMouseDownTimeout(); this.onStartDrag(...this.state.mouseDownPosition); } }