Skip to content

Commit bff3196

Browse files
RonnyChan96CodeCasterX
authored andcommitted
[elsa] elsa-react默认操作由选中改为拖拽画布 (#23)
* [elsa] elsa-react默认操作由选中改为拖拽画布 * [elsa] 检视意见修改:1.found声明和初始赋值改为同一行 2.抽取方法优化判断 * [elsa] 短路判断
1 parent 86ed003 commit bff3196

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

framework/elsa/fit-elsa-react/src/flow/jadeFlowPage.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {copyPasteHelper, ElsaCopyHandler, page, shapeDataHelper, sleep, uuid} fr
88
import {SYSTEM_ACTION, VIRTUAL_CONTEXT_NODE} from '@/common/Consts.js';
99
import {conditionRunner, inactiveNodeRunner, standardRunner} from '@/flow/runners.js';
1010
import {message} from 'antd';
11+
import {PAGE_OPERATION_MODE} from '@fit-elsa/elsa-core/common/const.js';
1112

1213
const START_NODE = 'startNodeStart';
1314

@@ -33,6 +34,7 @@ export const jadeFlowPage = (div, graph, name, id) => {
3334
self.gridColor = '#e1e1e3';
3435
self.disableContextMenu = true;
3536
self.moveAble = true;
37+
self.operationMode = PAGE_OPERATION_MODE.DRAG;
3638
self.observableStore = ObservableStore();
3739
self.copyPasteHelper = jadeCopyPasteHelper();
3840
const shapeChangeListener = (e) => self.graph.dirtied(null, {action: SYSTEM_ACTION.JADE_NODE_CONFIG_CHANGE, shape: e.shapeId});

framework/elsa/fit-elsa/core/page.js

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,9 +2370,6 @@ const setMouseActions = (pageVal) => {
23702370

23712371
pageVal.onMouseUp = position => {
23722372
pageVal.setCursor();
2373-
if (pageVal.operationMode === PAGE_OPERATION_MODE.DRAG) {
2374-
return;
2375-
}
23762373
let rect = {};
23772374
rect.x = (pageVal.mousedownx < pageVal.mousex ? pageVal.mousedownx : pageVal.mousex);
23782375
rect.y = (pageVal.mousedowny < pageVal.mousey ? pageVal.mousedowny : pageVal.mousey);
@@ -2404,20 +2401,19 @@ const setMouseActions = (pageVal) => {
24042401
pageVal.invalidateInteraction(position);
24052402
};
24062403

2404+
const shouldParentFocusFirst = (parent) => {
2405+
return parent.containerFocusFirst && !parent.hasChildFocused();
2406+
}
2407+
24072408
/**
24082409
* 鼠标点击时,得到的最符合条件的shape,没有condition,只要在坐标内,就可以得到
24092410
*/
24102411
pageVal.switchMouseInShape = (x, y, condition) => {
2411-
let found;
2412-
if (pageVal.operationMode === PAGE_OPERATION_MODE.DRAG) {
2413-
found = pageVal;
2414-
} else {
2415-
found = pageVal.find(x, y, condition ? condition : s => true);
2416-
const parent = found.getContainer();
2417-
const isNotFocused = !parent.isFocused && !found.isFocused;
2418-
if (parent.containerFocusFirst && isNotFocused && !parent.hasChildFocused()) {
2419-
found = parent;
2420-
}
2412+
let found = pageVal.find(x, y, condition ? condition : s => true);
2413+
const parent = found.getContainer();
2414+
const isNotFocused = !parent.isFocused && !found.isFocused;
2415+
if (isNotFocused && shouldParentFocusFirst(parent)) {
2416+
found = parent;
24212417
}
24222418
if (pageVal.mouseInShape !== found) {
24232419
const pre = pageVal.mouseInShape;
@@ -2527,10 +2523,6 @@ const setKeyActions = (pageVal) => {
25272523
pageVal.shiftKeyPressed = false;
25282524
pageVal.invalidateInteraction();
25292525
pageVal.isKeyDown = false;
2530-
if (e.code === 'Space' && pageVal.moveAble && pageVal.canvasMoveAble) {
2531-
pageVal.operationMode = PAGE_OPERATION_MODE.SELECTION;
2532-
return false;
2533-
}
25342526
const focused = pageVal.getFocusedShapes();
25352527
const isDirectionKey = e.key.indexOf('Left') >= 0 ||
25362528
e.key.indexOf('Right') >= 0 ||
@@ -2563,10 +2555,6 @@ const setKeyActions = (pageVal) => {
25632555
if (document.activeElement !== document.body) {
25642556
return true;
25652557
}
2566-
if (e.code === 'Space' && pageVal.moveAble && pageVal.canvasMoveAble) {
2567-
pageVal.operationMode = PAGE_OPERATION_MODE.DRAG;
2568-
return false;
2569-
}
25702558

25712559
let focused = pageVal.getFocusedShapes();
25722560
pageVal.ctrlKeyPressed = e.ctrlKey || e.metaKey;

0 commit comments

Comments
 (0)