Prevent accidental selection move (#848)
parent
1cd30205d9
commit
c0d0db4d7e
|
@ -24,6 +24,7 @@ const {
|
||||||
} = hstry
|
} = hstry
|
||||||
|
|
||||||
let svgCanvas = null
|
let svgCanvas = null
|
||||||
|
let moveSelectionThresholdReached = false
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function module:undo.init
|
* @function module:undo.init
|
||||||
|
@ -155,7 +156,13 @@ const mouseMoveEvent = (evt) => {
|
||||||
dy = snapToGrid(dy)
|
dy = snapToGrid(dy)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dx || dy) {
|
// Enable moving selection only if mouse has been moved at least 4 px in any direction
|
||||||
|
// This prevents objects from being accidentally moved when (initially) selected
|
||||||
|
const deltaThreshold = 4
|
||||||
|
const deltaThresholdReached = Math.abs(dx) > deltaThreshold || Math.abs(dy) > deltaThreshold
|
||||||
|
moveSelectionThresholdReached = moveSelectionThresholdReached || deltaThresholdReached
|
||||||
|
|
||||||
|
if (moveSelectionThresholdReached) {
|
||||||
selectedElements.forEach((el) => {
|
selectedElements.forEach((el) => {
|
||||||
if (el) {
|
if (el) {
|
||||||
updateTransformList(svgRoot, el, dx, dy)
|
updateTransformList(svgRoot, el, dx, dy)
|
||||||
|
@ -563,6 +570,7 @@ const mouseOutEvent = () => {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const mouseUpEvent = (evt) => {
|
const mouseUpEvent = (evt) => {
|
||||||
|
moveSelectionThresholdReached = false
|
||||||
if (evt.button === 2) { return }
|
if (evt.button === 2) { return }
|
||||||
if (!svgCanvas.getStarted()) { return }
|
if (!svgCanvas.getStarted()) { return }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue