@logicflow/extension 2.1.6 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,6 +17,9 @@ var DndPanel = /** @class */ (function () {
17
17
  }
18
18
  this.panelEl = document.createElement('div');
19
19
  this.panelEl.className = 'lf-dndpanel';
20
+ this.panelEl.addEventListener('touchmove', function (e) {
21
+ e.preventDefault();
22
+ }, { passive: false });
20
23
  this.shapeList.forEach(function (shapeItem) {
21
24
  var _a;
22
25
  (_a = _this.panelEl) === null || _a === void 0 ? void 0 : _a.appendChild(_this.createDndItem(shapeItem));
@@ -63,14 +66,14 @@ var DndPanel = /** @class */ (function () {
63
66
  if (shapeItem.disabled) {
64
67
  el.classList.add('disabled');
65
68
  // 保留callback的执行,可用于界面提示当前shapeItem的禁用状态
66
- el.onmousedown = function () {
69
+ el.onpointerdown = function () {
67
70
  if (shapeItem.callback) {
68
71
  shapeItem.callback(_this.lf, _this.domContainer);
69
72
  }
70
73
  };
71
74
  return el;
72
75
  }
73
- el.onmousedown = function () {
76
+ el.onpointerdown = function (e) {
74
77
  if (shapeItem.type) {
75
78
  _this.lf.dnd.startDrag({
76
79
  type: shapeItem.type,
@@ -81,6 +84,7 @@ var DndPanel = /** @class */ (function () {
81
84
  if (shapeItem.callback) {
82
85
  shapeItem.callback(_this.lf, _this.domContainer);
83
86
  }
87
+ e.preventDefault();
84
88
  };
85
89
  el.ondblclick = function (e) {
86
90
  _this.lf.graphModel.eventCenter.emit('dnd:panel-dbclick', {
@@ -179,8 +179,8 @@ var MiniMap = /** @class */ (function () {
179
179
  }
180
180
  };
181
181
  this.startDrag = function (e) {
182
- document.addEventListener('mousemove', _this.drag);
183
- document.addEventListener('mouseup', _this.drop);
182
+ document.addEventListener('pointermove', _this.drag);
183
+ document.addEventListener('pointerup', _this.drop);
184
184
  var x = e.x, y = e.y;
185
185
  _this.startPosition = { x: x, y: y };
186
186
  };
@@ -206,8 +206,8 @@ var MiniMap = /** @class */ (function () {
206
206
  * 拖拽预览视窗结束,移除拖拽事件
207
207
  */
208
208
  this.drop = function () {
209
- document.removeEventListener('mousemove', _this.drag);
210
- document.removeEventListener('mouseup', _this.drop);
209
+ document.removeEventListener('pointermove', _this.drag);
210
+ document.removeEventListener('pointerup', _this.drop);
211
211
  };
212
212
  /**
213
213
  * 点击小地图中非预览视窗的区域时,移动主画布视口聚焦于点击位置
@@ -513,8 +513,8 @@ var MiniMap = /** @class */ (function () {
513
513
  MiniMap.prototype.createViewPort = function () {
514
514
  var div = document.createElement('div');
515
515
  div.className = 'lf-minimap-viewport';
516
- // 拖拽预览视窗,主画布视口跟随移动
517
- div.addEventListener('mousedown', this.startDrag);
516
+ div.style.touchAction = 'none';
517
+ div.addEventListener('pointerdown', this.startDrag);
518
518
  // 禁止预览视窗的点击事件冒泡
519
519
  div.addEventListener('click', function (e) {
520
520
  e.stopPropagation();
@@ -46,6 +46,12 @@ var SelectionSelect = /** @class */ (function () {
46
46
  _this.handleMouseDown(e);
47
47
  };
48
48
  this.draw = function (ev) {
49
+ if (_this.lf.graphModel.editConfigModel.isPinching) {
50
+ _this.lf.updateEditConfig({ stopMoveGraph: _this.originalStopMoveGraph });
51
+ _this.originStatusSaved = false;
52
+ _this.cleanupSelectionState();
53
+ return;
54
+ }
49
55
  var _a = _this.lf.getPointByClient(ev.clientX, ev.clientY).domOverlayPosition, x1 = _a.x, y1 = _a.y;
50
56
  _this.endPoint = {
51
57
  x: x1,
@@ -94,9 +100,9 @@ var SelectionSelect = /** @class */ (function () {
94
100
  }
95
101
  var curStartPoint = cloneDeep(_this.startPoint);
96
102
  var curEndPoint = cloneDeep(_this.endPoint);
97
- document.removeEventListener('mousemove', _this.draw);
103
+ document.removeEventListener('pointermove', _this.draw);
98
104
  if (!_this.exclusiveMode) {
99
- document.removeEventListener('mouseup', _this.drawOff);
105
+ document.removeEventListener('pointerup', _this.drawOff);
100
106
  }
101
107
  if (curStartPoint && curEndPoint) {
102
108
  var x = curStartPoint.x, y = curStartPoint.y;
@@ -210,8 +216,8 @@ var SelectionSelect = /** @class */ (function () {
210
216
  this.endPoint = undefined;
211
217
  this.mouseDownInfo = null;
212
218
  // 移除事件监听
213
- document.removeEventListener('mousemove', this.draw);
214
- document.removeEventListener('mouseup', this.drawOff);
219
+ document.removeEventListener('pointermove', this.draw);
220
+ document.removeEventListener('pointerup', this.drawOff);
215
221
  };
216
222
  /**
217
223
  * 切换框选模式
@@ -235,7 +241,8 @@ var SelectionSelect = /** @class */ (function () {
235
241
  if (this.exclusiveMode) {
236
242
  // 独占模式:监听 container 的 mousedown 事件
237
243
  this.container.style.pointerEvents = 'auto';
238
- this.container.addEventListener('mousedown', this.handleMouseDown);
244
+ this.container.style.touchAction = 'none';
245
+ this.container.addEventListener('pointerdown', this.handleMouseDown);
239
246
  }
240
247
  else {
241
248
  // 非独占模式:监听画布的 blank:mousedown 事件
@@ -247,7 +254,7 @@ var SelectionSelect = /** @class */ (function () {
247
254
  SelectionSelect.prototype.removeEventListeners = function () {
248
255
  if (this.container) {
249
256
  this.container.style.pointerEvents = 'none';
250
- this.container.removeEventListener('mousedown', this.handleMouseDown);
257
+ this.container.removeEventListener('pointerdown', this.handleMouseDown);
251
258
  }
252
259
  // 移除 blank:mousedown 事件监听
253
260
  this.lf.off('blank:mousedown', this.handleBlankMouseDown);
@@ -259,6 +266,8 @@ var SelectionSelect = /** @class */ (function () {
259
266
  var _a;
260
267
  if (!this.container || this.disabled)
261
268
  return;
269
+ if (this.lf.graphModel.editConfigModel.isPinching)
270
+ return;
262
271
  // 禁用右键框选
263
272
  var isRightClick = e.button === 2;
264
273
  if (isRightClick)
@@ -292,8 +301,8 @@ var SelectionSelect = /** @class */ (function () {
292
301
  wrapper.style.left = "".concat(this.startPoint.x, "px");
293
302
  (_a = this.container) === null || _a === void 0 ? void 0 : _a.appendChild(wrapper);
294
303
  this.wrapper = wrapper;
295
- document.addEventListener('mousemove', this.draw);
296
- document.addEventListener('mouseup', this.drawOff);
304
+ document.addEventListener('pointermove', this.draw);
305
+ document.addEventListener('pointerup', this.drawOff);
297
306
  };
298
307
  /**
299
308
  * 设置选中的灵敏度
@@ -331,7 +340,7 @@ var SelectionSelect = /** @class */ (function () {
331
340
  if (this.wrapper && this.startPoint && this.endPoint) {
332
341
  // 记录上一次的结束点,用于触发 mouseup 事件
333
342
  var lastEndPoint = cloneDeep(this.endPoint);
334
- var lastEvent = new MouseEvent('mouseup', {
343
+ var lastEvent = new PointerEvent('pointerup', {
335
344
  clientX: lastEndPoint.x,
336
345
  clientY: lastEndPoint.y,
337
346
  });
@@ -17,8 +17,8 @@ export declare class Label extends Component<ILabelProps, ILabelState> {
17
17
  constructor(props: ILabelProps);
18
18
  setHoverOn: () => void;
19
19
  setHoverOff: () => void;
20
- handleMouseDown: (e: MouseEvent) => void;
21
- handleMouseUp: (e: MouseEvent) => void;
20
+ handleMouseDown: (e: PointerEvent) => void;
21
+ handleMouseUp: (e: PointerEvent) => void;
22
22
  handleDragging: ({ deltaX, deltaY }: IDragParams) => void;
23
23
  handleDragEnd: () => void;
24
24
  handleClick: (e: MouseEvent) => void;
@@ -274,7 +274,7 @@ var Label = /** @class */ (function (_super) {
274
274
  ? "".concat(transform, " rotate(").concat(rotate, "deg)")
275
275
  : "".concat(transform, " rotate(").concat(vertical ? -0.25 : 0, "turn)"),
276
276
  };
277
- return (_jsx("div", { id: "element-container-".concat(id), className: classNames('lf-label-editor-container'), style: containerStyle, onMouseDown: this.handleMouseDown, onMouseUp: this.handleMouseUp, onClick: this.handleClick, onDblClick: this.handleDbClick, onBlur: this.handleBlur, onMouseEnter: this.setHoverOn, onMouseOver: this.setHoverOn, onMouseLeave: this.setHoverOff, children: _jsx("div", { ref: this.textRef, id: "editor-container-".concat(id), className: classNames('lf-label-editor', (_a = {
277
+ return (_jsx("div", { id: "element-container-".concat(id), className: classNames('lf-label-editor-container'), style: containerStyle, onPointerDown: this.handleMouseDown, onPointerUp: this.handleMouseUp, onClick: this.handleClick, onDblClick: this.handleDbClick, onBlur: this.handleBlur, onMouseEnter: this.setHoverOn, onMouseOver: this.setHoverOn, onMouseLeave: this.setHoverOff, children: _jsx("div", { ref: this.textRef, id: "editor-container-".concat(id), className: classNames('lf-label-editor', (_a = {
278
278
  'lf-label-editor-dragging': isDragging,
279
279
  'lf-label-editor-editing': isEditing,
280
280
  'lf-label-editor-hover': !isEditing && (isHovered || isSelected)
@@ -20,6 +20,9 @@ var DndPanel = /** @class */ (function () {
20
20
  }
21
21
  this.panelEl = document.createElement('div');
22
22
  this.panelEl.className = 'lf-dndpanel';
23
+ this.panelEl.addEventListener('touchmove', function (e) {
24
+ e.preventDefault();
25
+ }, { passive: false });
23
26
  this.shapeList.forEach(function (shapeItem) {
24
27
  var _a;
25
28
  (_a = _this.panelEl) === null || _a === void 0 ? void 0 : _a.appendChild(_this.createDndItem(shapeItem));
@@ -66,14 +69,14 @@ var DndPanel = /** @class */ (function () {
66
69
  if (shapeItem.disabled) {
67
70
  el.classList.add('disabled');
68
71
  // 保留callback的执行,可用于界面提示当前shapeItem的禁用状态
69
- el.onmousedown = function () {
72
+ el.onpointerdown = function () {
70
73
  if (shapeItem.callback) {
71
74
  shapeItem.callback(_this.lf, _this.domContainer);
72
75
  }
73
76
  };
74
77
  return el;
75
78
  }
76
- el.onmousedown = function () {
79
+ el.onpointerdown = function (e) {
77
80
  if (shapeItem.type) {
78
81
  _this.lf.dnd.startDrag({
79
82
  type: shapeItem.type,
@@ -84,6 +87,7 @@ var DndPanel = /** @class */ (function () {
84
87
  if (shapeItem.callback) {
85
88
  shapeItem.callback(_this.lf, _this.domContainer);
86
89
  }
90
+ e.preventDefault();
87
91
  };
88
92
  el.ondblclick = function (e) {
89
93
  _this.lf.graphModel.eventCenter.emit('dnd:panel-dbclick', {
@@ -182,8 +182,8 @@ var MiniMap = /** @class */ (function () {
182
182
  }
183
183
  };
184
184
  this.startDrag = function (e) {
185
- document.addEventListener('mousemove', _this.drag);
186
- document.addEventListener('mouseup', _this.drop);
185
+ document.addEventListener('pointermove', _this.drag);
186
+ document.addEventListener('pointerup', _this.drop);
187
187
  var x = e.x, y = e.y;
188
188
  _this.startPosition = { x: x, y: y };
189
189
  };
@@ -209,8 +209,8 @@ var MiniMap = /** @class */ (function () {
209
209
  * 拖拽预览视窗结束,移除拖拽事件
210
210
  */
211
211
  this.drop = function () {
212
- document.removeEventListener('mousemove', _this.drag);
213
- document.removeEventListener('mouseup', _this.drop);
212
+ document.removeEventListener('pointermove', _this.drag);
213
+ document.removeEventListener('pointerup', _this.drop);
214
214
  };
215
215
  /**
216
216
  * 点击小地图中非预览视窗的区域时,移动主画布视口聚焦于点击位置
@@ -516,8 +516,8 @@ var MiniMap = /** @class */ (function () {
516
516
  MiniMap.prototype.createViewPort = function () {
517
517
  var div = document.createElement('div');
518
518
  div.className = 'lf-minimap-viewport';
519
- // 拖拽预览视窗,主画布视口跟随移动
520
- div.addEventListener('mousedown', this.startDrag);
519
+ div.style.touchAction = 'none';
520
+ div.addEventListener('pointerdown', this.startDrag);
521
521
  // 禁止预览视窗的点击事件冒泡
522
522
  div.addEventListener('click', function (e) {
523
523
  e.stopPropagation();
@@ -49,6 +49,12 @@ var SelectionSelect = /** @class */ (function () {
49
49
  _this.handleMouseDown(e);
50
50
  };
51
51
  this.draw = function (ev) {
52
+ if (_this.lf.graphModel.editConfigModel.isPinching) {
53
+ _this.lf.updateEditConfig({ stopMoveGraph: _this.originalStopMoveGraph });
54
+ _this.originStatusSaved = false;
55
+ _this.cleanupSelectionState();
56
+ return;
57
+ }
52
58
  var _a = _this.lf.getPointByClient(ev.clientX, ev.clientY).domOverlayPosition, x1 = _a.x, y1 = _a.y;
53
59
  _this.endPoint = {
54
60
  x: x1,
@@ -97,9 +103,9 @@ var SelectionSelect = /** @class */ (function () {
97
103
  }
98
104
  var curStartPoint = (0, lodash_es_1.cloneDeep)(_this.startPoint);
99
105
  var curEndPoint = (0, lodash_es_1.cloneDeep)(_this.endPoint);
100
- document.removeEventListener('mousemove', _this.draw);
106
+ document.removeEventListener('pointermove', _this.draw);
101
107
  if (!_this.exclusiveMode) {
102
- document.removeEventListener('mouseup', _this.drawOff);
108
+ document.removeEventListener('pointerup', _this.drawOff);
103
109
  }
104
110
  if (curStartPoint && curEndPoint) {
105
111
  var x = curStartPoint.x, y = curStartPoint.y;
@@ -213,8 +219,8 @@ var SelectionSelect = /** @class */ (function () {
213
219
  this.endPoint = undefined;
214
220
  this.mouseDownInfo = null;
215
221
  // 移除事件监听
216
- document.removeEventListener('mousemove', this.draw);
217
- document.removeEventListener('mouseup', this.drawOff);
222
+ document.removeEventListener('pointermove', this.draw);
223
+ document.removeEventListener('pointerup', this.drawOff);
218
224
  };
219
225
  /**
220
226
  * 切换框选模式
@@ -238,7 +244,8 @@ var SelectionSelect = /** @class */ (function () {
238
244
  if (this.exclusiveMode) {
239
245
  // 独占模式:监听 container 的 mousedown 事件
240
246
  this.container.style.pointerEvents = 'auto';
241
- this.container.addEventListener('mousedown', this.handleMouseDown);
247
+ this.container.style.touchAction = 'none';
248
+ this.container.addEventListener('pointerdown', this.handleMouseDown);
242
249
  }
243
250
  else {
244
251
  // 非独占模式:监听画布的 blank:mousedown 事件
@@ -250,7 +257,7 @@ var SelectionSelect = /** @class */ (function () {
250
257
  SelectionSelect.prototype.removeEventListeners = function () {
251
258
  if (this.container) {
252
259
  this.container.style.pointerEvents = 'none';
253
- this.container.removeEventListener('mousedown', this.handleMouseDown);
260
+ this.container.removeEventListener('pointerdown', this.handleMouseDown);
254
261
  }
255
262
  // 移除 blank:mousedown 事件监听
256
263
  this.lf.off('blank:mousedown', this.handleBlankMouseDown);
@@ -262,6 +269,8 @@ var SelectionSelect = /** @class */ (function () {
262
269
  var _a;
263
270
  if (!this.container || this.disabled)
264
271
  return;
272
+ if (this.lf.graphModel.editConfigModel.isPinching)
273
+ return;
265
274
  // 禁用右键框选
266
275
  var isRightClick = e.button === 2;
267
276
  if (isRightClick)
@@ -295,8 +304,8 @@ var SelectionSelect = /** @class */ (function () {
295
304
  wrapper.style.left = "".concat(this.startPoint.x, "px");
296
305
  (_a = this.container) === null || _a === void 0 ? void 0 : _a.appendChild(wrapper);
297
306
  this.wrapper = wrapper;
298
- document.addEventListener('mousemove', this.draw);
299
- document.addEventListener('mouseup', this.drawOff);
307
+ document.addEventListener('pointermove', this.draw);
308
+ document.addEventListener('pointerup', this.drawOff);
300
309
  };
301
310
  /**
302
311
  * 设置选中的灵敏度
@@ -334,7 +343,7 @@ var SelectionSelect = /** @class */ (function () {
334
343
  if (this.wrapper && this.startPoint && this.endPoint) {
335
344
  // 记录上一次的结束点,用于触发 mouseup 事件
336
345
  var lastEndPoint = (0, lodash_es_1.cloneDeep)(this.endPoint);
337
- var lastEvent = new MouseEvent('mouseup', {
346
+ var lastEvent = new PointerEvent('pointerup', {
338
347
  clientX: lastEndPoint.x,
339
348
  clientY: lastEndPoint.y,
340
349
  });
@@ -17,8 +17,8 @@ export declare class Label extends Component<ILabelProps, ILabelState> {
17
17
  constructor(props: ILabelProps);
18
18
  setHoverOn: () => void;
19
19
  setHoverOff: () => void;
20
- handleMouseDown: (e: MouseEvent) => void;
21
- handleMouseUp: (e: MouseEvent) => void;
20
+ handleMouseDown: (e: PointerEvent) => void;
21
+ handleMouseUp: (e: PointerEvent) => void;
22
22
  handleDragging: ({ deltaX, deltaY }: IDragParams) => void;
23
23
  handleDragEnd: () => void;
24
24
  handleClick: (e: MouseEvent) => void;
@@ -280,7 +280,7 @@ var Label = /** @class */ (function (_super) {
280
280
  ? "".concat(transform, " rotate(").concat(rotate, "deg)")
281
281
  : "".concat(transform, " rotate(").concat(vertical ? -0.25 : 0, "turn)"),
282
282
  };
283
- return ((0, jsx_runtime_1.jsx)("div", { id: "element-container-".concat(id), className: (0, classnames_1.default)('lf-label-editor-container'), style: containerStyle, onMouseDown: this.handleMouseDown, onMouseUp: this.handleMouseUp, onClick: this.handleClick, onDblClick: this.handleDbClick, onBlur: this.handleBlur, onMouseEnter: this.setHoverOn, onMouseOver: this.setHoverOn, onMouseLeave: this.setHoverOff, children: (0, jsx_runtime_1.jsx)("div", { ref: this.textRef, id: "editor-container-".concat(id), className: (0, classnames_1.default)('lf-label-editor', (_a = {
283
+ return ((0, jsx_runtime_1.jsx)("div", { id: "element-container-".concat(id), className: (0, classnames_1.default)('lf-label-editor-container'), style: containerStyle, onPointerDown: this.handleMouseDown, onPointerUp: this.handleMouseUp, onClick: this.handleClick, onDblClick: this.handleDbClick, onBlur: this.handleBlur, onMouseEnter: this.setHoverOn, onMouseOver: this.setHoverOn, onMouseLeave: this.setHoverOff, children: (0, jsx_runtime_1.jsx)("div", { ref: this.textRef, id: "editor-container-".concat(id), className: (0, classnames_1.default)('lf-label-editor', (_a = {
284
284
  'lf-label-editor-dragging': isDragging,
285
285
  'lf-label-editor-editing': isEditing,
286
286
  'lf-label-editor-hover': !isEditing && (isHovered || isSelected)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logicflow/extension",
3
- "version": "2.1.6",
3
+ "version": "2.2.0",
4
4
  "description": "LogicFlow Extensions",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -20,8 +20,8 @@
20
20
  "author": "Logicflow-Team",
21
21
  "license": "Apache-2.0",
22
22
  "peerDependencies": {
23
- "@logicflow/core": "2.1.4",
24
- "@logicflow/vue-node-registry": "1.1.5"
23
+ "@logicflow/vue-node-registry": "1.2.0",
24
+ "@logicflow/core": "2.2.0"
25
25
  },
26
26
  "dependencies": {
27
27
  "@antv/hierarchy": "^0.6.11",
@@ -32,8 +32,8 @@
32
32
  "preact": "^10.17.1",
33
33
  "rangy": "^1.3.1",
34
34
  "vanilla-picker": "^2.12.3",
35
- "@logicflow/core": "2.1.4",
36
- "@logicflow/vue-node-registry": "1.1.5"
35
+ "@logicflow/core": "2.2.0",
36
+ "@logicflow/vue-node-registry": "1.2.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "less": "^4.1.1",
@@ -36,6 +36,13 @@ export class DndPanel {
36
36
  }
37
37
  this.panelEl = document.createElement('div')
38
38
  this.panelEl.className = 'lf-dndpanel'
39
+ this.panelEl.addEventListener(
40
+ 'touchmove',
41
+ (e) => {
42
+ e.preventDefault()
43
+ },
44
+ { passive: false },
45
+ )
39
46
  this.shapeList.forEach((shapeItem) => {
40
47
  this.panelEl?.appendChild(this.createDndItem(shapeItem))
41
48
  })
@@ -85,14 +92,14 @@ export class DndPanel {
85
92
  if (shapeItem.disabled) {
86
93
  el.classList.add('disabled')
87
94
  // 保留callback的执行,可用于界面提示当前shapeItem的禁用状态
88
- el.onmousedown = () => {
95
+ el.onpointerdown = () => {
89
96
  if (shapeItem.callback) {
90
97
  shapeItem.callback(this.lf, this.domContainer)
91
98
  }
92
99
  }
93
100
  return el
94
101
  }
95
- el.onmousedown = () => {
102
+ el.onpointerdown = (e: PointerEvent) => {
96
103
  if (shapeItem.type) {
97
104
  this.lf.dnd.startDrag({
98
105
  type: shapeItem.type,
@@ -103,6 +110,7 @@ export class DndPanel {
103
110
  if (shapeItem.callback) {
104
111
  shapeItem.callback(this.lf, this.domContainer)
105
112
  }
113
+ e.preventDefault()
106
114
  }
107
115
  el.ondblclick = (e) => {
108
116
  this.lf.graphModel.eventCenter.emit('dnd:panel-dbclick', {
@@ -603,7 +603,6 @@ class Menu {
603
603
  if (lf.graphModel.editConfigModel.isSilentMode) return
604
604
  this.__container = container
605
605
  this.__currentData = null // 当前展示的菜单所属元素的model数据
606
-
607
606
  // 监听 isSilentMode 变化
608
607
  this.setupSilentModeListener()
609
608
 
@@ -616,8 +616,8 @@ export class MiniMap {
616
616
  const div = document.createElement('div')
617
617
  div.className = 'lf-minimap-viewport'
618
618
 
619
- // 拖拽预览视窗,主画布视口跟随移动
620
- div.addEventListener('mousedown', this.startDrag)
619
+ div.style.touchAction = 'none'
620
+ div.addEventListener('pointerdown', this.startDrag)
621
621
 
622
622
  // 禁止预览视窗的点击事件冒泡
623
623
  div.addEventListener('click', (e: MouseEvent) => {
@@ -626,9 +626,9 @@ export class MiniMap {
626
626
  this.viewport = div
627
627
  }
628
628
 
629
- private startDrag = (e: MouseEvent) => {
630
- document.addEventListener('mousemove', this.drag)
631
- document.addEventListener('mouseup', this.drop)
629
+ private startDrag = (e: PointerEvent) => {
630
+ document.addEventListener('pointermove', this.drag)
631
+ document.addEventListener('pointerup', this.drop)
632
632
  const { x, y } = e
633
633
  this.startPosition = { x, y }
634
634
  }
@@ -636,7 +636,7 @@ export class MiniMap {
636
636
  /**
637
637
  * 拖拽预览视窗过程中,更新主画布视口
638
638
  */
639
- private drag = (e: MouseEvent) => {
639
+ private drag = (e: PointerEvent) => {
640
640
  const { x, y } = e
641
641
  const translateX = (x - this.startPosition.x) / this.scale
642
642
  const translateY = (y - this.startPosition.y) / this.scale
@@ -659,8 +659,8 @@ export class MiniMap {
659
659
  * 拖拽预览视窗结束,移除拖拽事件
660
660
  */
661
661
  private drop = () => {
662
- document.removeEventListener('mousemove', this.drag)
663
- document.removeEventListener('mouseup', this.drop)
662
+ document.removeEventListener('pointermove', this.drag)
663
+ document.removeEventListener('pointerup', this.drop)
664
664
  }
665
665
 
666
666
  /**
@@ -76,8 +76,8 @@ export class SelectionSelect {
76
76
  this.mouseDownInfo = null
77
77
 
78
78
  // 移除事件监听
79
- document.removeEventListener('mousemove', this.draw)
80
- document.removeEventListener('mouseup', this.drawOff)
79
+ document.removeEventListener('pointermove', this.draw)
80
+ document.removeEventListener('pointerup', this.drawOff)
81
81
  }
82
82
 
83
83
  /**
@@ -101,7 +101,8 @@ export class SelectionSelect {
101
101
  if (this.exclusiveMode) {
102
102
  // 独占模式:监听 container 的 mousedown 事件
103
103
  this.container.style.pointerEvents = 'auto'
104
- this.container.addEventListener('mousedown', this.handleMouseDown)
104
+ this.container.style.touchAction = 'none'
105
+ this.container.addEventListener('pointerdown', this.handleMouseDown)
105
106
  } else {
106
107
  // 非独占模式:监听画布的 blank:mousedown 事件
107
108
  this.container.style.pointerEvents = 'none'
@@ -113,7 +114,7 @@ export class SelectionSelect {
113
114
  private removeEventListeners() {
114
115
  if (this.container) {
115
116
  this.container.style.pointerEvents = 'none'
116
- this.container.removeEventListener('mousedown', this.handleMouseDown)
117
+ this.container.removeEventListener('pointerdown', this.handleMouseDown)
117
118
  }
118
119
  // 移除 blank:mousedown 事件监听
119
120
  this.lf.off('blank:mousedown', this.handleBlankMouseDown)
@@ -122,15 +123,16 @@ export class SelectionSelect {
122
123
  /**
123
124
  * 处理画布空白处鼠标按下事件(非独占模式)
124
125
  */
125
- private handleBlankMouseDown = ({ e }: { e: MouseEvent }) => {
126
- this.handleMouseDown(e)
126
+ private handleBlankMouseDown = ({ e }: { e: MouseEvent | PointerEvent }) => {
127
+ this.handleMouseDown(e as PointerEvent)
127
128
  }
128
129
 
129
130
  /**
130
131
  * 处理鼠标按下事件
131
132
  */
132
- private handleMouseDown(e: MouseEvent) {
133
+ private handleMouseDown(e: PointerEvent) {
133
134
  if (!this.container || this.disabled) return
135
+ if (this.lf.graphModel.editConfigModel.isPinching) return
134
136
 
135
137
  // 禁用右键框选
136
138
  const isRightClick = e.button === 2
@@ -170,8 +172,8 @@ export class SelectionSelect {
170
172
  this.container?.appendChild(wrapper)
171
173
  this.wrapper = wrapper
172
174
 
173
- document.addEventListener('mousemove', this.draw)
174
- document.addEventListener('mouseup', this.drawOff)
175
+ document.addEventListener('pointermove', this.draw)
176
+ document.addEventListener('pointerup', this.drawOff)
175
177
  }
176
178
 
177
179
  /**
@@ -210,7 +212,7 @@ export class SelectionSelect {
210
212
  if (this.wrapper && this.startPoint && this.endPoint) {
211
213
  // 记录上一次的结束点,用于触发 mouseup 事件
212
214
  const lastEndPoint = cloneDeep(this.endPoint)
213
- const lastEvent = new MouseEvent('mouseup', {
215
+ const lastEvent = new PointerEvent('pointerup', {
214
216
  clientX: lastEndPoint.x,
215
217
  clientY: lastEndPoint.y,
216
218
  })
@@ -221,7 +223,13 @@ export class SelectionSelect {
221
223
  this.close()
222
224
  }
223
225
 
224
- private draw = (ev: MouseEvent) => {
226
+ private draw = (ev: PointerEvent) => {
227
+ if (this.lf.graphModel.editConfigModel.isPinching) {
228
+ this.lf.updateEditConfig({ stopMoveGraph: this.originalStopMoveGraph })
229
+ this.originStatusSaved = false
230
+ this.cleanupSelectionState()
231
+ return
232
+ }
225
233
  const {
226
234
  domOverlayPosition: { x: x1, y: y1 },
227
235
  } = this.lf.getPointByClient(ev.clientX, ev.clientY)
@@ -251,7 +259,7 @@ export class SelectionSelect {
251
259
  }
252
260
  }
253
261
  }
254
- private drawOff = (e: MouseEvent) => {
262
+ private drawOff = (e: PointerEvent) => {
255
263
  // 恢复原始的 stopMoveGraph 设置
256
264
  this.lf.updateEditConfig({
257
265
  stopMoveGraph: this.originalStopMoveGraph,
@@ -274,9 +282,9 @@ export class SelectionSelect {
274
282
 
275
283
  const curStartPoint = cloneDeep(this.startPoint)
276
284
  const curEndPoint = cloneDeep(this.endPoint)
277
- document.removeEventListener('mousemove', this.draw)
285
+ document.removeEventListener('pointermove', this.draw)
278
286
  if (!this.exclusiveMode) {
279
- document.removeEventListener('mouseup', this.drawOff)
287
+ document.removeEventListener('pointerup', this.drawOff)
280
288
  }
281
289
 
282
290
  if (curStartPoint && curEndPoint) {
@@ -72,7 +72,7 @@ export class Label extends Component<ILabelProps, ILabelState> {
72
72
  element.setHovered(false)
73
73
  }
74
74
 
75
- handleMouseDown = (e: MouseEvent) => {
75
+ handleMouseDown = (e: PointerEvent) => {
76
76
  const { label, graphModel } = this.props
77
77
  const {
78
78
  editConfigModel: { nodeTextDraggable },
@@ -86,7 +86,7 @@ export class Label extends Component<ILabelProps, ILabelState> {
86
86
  this.stepDrag.handleMouseDown(e)
87
87
  }
88
88
  }
89
- handleMouseUp = (e: MouseEvent) => {
89
+ handleMouseUp = (e: PointerEvent) => {
90
90
  if (this.state.isDragging) {
91
91
  this.stepDrag.handleMouseUp(e)
92
92
  }
@@ -320,8 +320,8 @@ export class Label extends Component<ILabelProps, ILabelState> {
320
320
  id={`element-container-${id}`}
321
321
  className={classNames('lf-label-editor-container')}
322
322
  style={containerStyle}
323
- onMouseDown={this.handleMouseDown}
324
- onMouseUp={this.handleMouseUp}
323
+ onPointerDown={this.handleMouseDown}
324
+ onPointerUp={this.handleMouseUp}
325
325
  onClick={this.handleClick}
326
326
  onDblClick={this.handleDbClick}
327
327
  onBlur={this.handleBlur}