mirror of
https://github.com/stan-smith/FossFLOW.git
synced 2025-12-24 06:58:48 -05:00
fix: issue with skipping tiles while dragging nodes
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { produce } from 'immer';
|
||||
import { CoordsUtils } from 'src/utils';
|
||||
import { InteractionReducer } from 'src/types';
|
||||
|
||||
export const DragItems: InteractionReducer = {
|
||||
@@ -11,31 +10,27 @@ export const DragItems: InteractionReducer = {
|
||||
draftState.rendererRef.style.userSelect = 'auto';
|
||||
},
|
||||
mousemove: (draftState) => {
|
||||
if (draftState.mode.type !== 'DRAG_ITEMS') return;
|
||||
if (draftState.mode.type !== 'DRAG_ITEMS' || !draftState.mouse.mousedown)
|
||||
return;
|
||||
|
||||
if (
|
||||
draftState.mouse.delta !== null &&
|
||||
!CoordsUtils.isEqual(draftState.mouse.delta.tile, CoordsUtils.zero())
|
||||
) {
|
||||
// User has moved tile since the last mouse event
|
||||
const newScene = draftState.mode.items.reduce((acc, node) => {
|
||||
return produce(acc, (draft) => {
|
||||
const afterNodeUpdates = draftState.sceneActions.updateNode(
|
||||
node.id,
|
||||
{
|
||||
position: draftState.mouse.position.tile
|
||||
},
|
||||
acc
|
||||
);
|
||||
// User is dragging
|
||||
const newScene = draftState.mode.items.reduce((acc, node) => {
|
||||
return produce(acc, (draft) => {
|
||||
const afterNodeUpdates = draftState.sceneActions.updateNode(
|
||||
node.id,
|
||||
{
|
||||
position: draftState.mouse.position.tile
|
||||
},
|
||||
acc
|
||||
);
|
||||
|
||||
draft.nodes = afterNodeUpdates.nodes;
|
||||
draft.connectors = afterNodeUpdates.connectors;
|
||||
});
|
||||
}, draftState.scene);
|
||||
draft.nodes = afterNodeUpdates.nodes;
|
||||
draft.connectors = afterNodeUpdates.connectors;
|
||||
});
|
||||
}, draftState.scene);
|
||||
|
||||
draftState.scene = newScene;
|
||||
draftState.contextMenu = null;
|
||||
}
|
||||
draftState.scene = newScene;
|
||||
draftState.contextMenu = null;
|
||||
},
|
||||
mouseup: (draftState) => {
|
||||
draftState.mode = { type: 'CURSOR', showCursor: true, mousedown: null };
|
||||
|
||||
Reference in New Issue
Block a user