From fc680545ad976fc3c94326d5e1e9fce29bee9cc5 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Fri, 22 Dec 2017 13:58:27 -0500 Subject: [PATCH] Don't dispatch drag start and move together Drag start is responsible for switching into drag mode, classing stuff as `active` and kicking off a bunch of other things. If the drag move happens immediately after this, and includes the target from the initial active drag, it can cause weird snapping from the dragnode to its own parent way. (Happened if the user did a very fast drag from the node along the parent way just next to it) --- modules/behavior/drag.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/behavior/drag.js b/modules/behavior/drag.js index 52e9fb7ff..b9ea9c0af 100644 --- a/modules/behavior/drag.js +++ b/modules/behavior/drag.js @@ -110,19 +110,19 @@ export function behaviorDrag() { if (dx === 0 && dy === 0) return; - if (!started) { - started = true; - _event({ type: 'start' }); - } - startOrigin = p; d3_eventCancel(); - _event({ - type: 'move', - point: [p[0] + offset[0], p[1] + offset[1]], - delta: [dx, dy] - }); + if (!started) { + started = true; + _event({ type: 'start' }); + } else { + _event({ + type: 'move', + point: [p[0] + offset[0], p[1] + offset[1]], + delta: [dx, dy] + }); + } }