@logicflow/extension 2.0.12 → 2.0.13
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.
- package/.turbo/turbo-build.log +17 -9
- package/CHANGELOG.md +8 -0
- package/dist/index.css +1 -278
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/es/bpmn-elements/presets/Pool/Pool.d.ts +2 -2
- package/es/components/mini-map/index.d.ts +2 -0
- package/es/components/mini-map/index.js +10 -0
- package/es/index.css +1 -278
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/style/index.css +1 -278
- package/es/style/raw.d.ts +1 -1
- package/es/style/raw.js +1 -1
- package/es/tools/label/Label.d.ts +4 -0
- package/es/tools/label/Label.js +75 -31
- package/es/tools/label/LabelModel.js +1 -0
- package/es/tools/label/index.d.ts +1 -0
- package/es/tools/label/index.js +47 -3
- package/es/tools/proximity-connect/index.d.ts +42 -0
- package/es/tools/proximity-connect/index.js +337 -0
- package/lib/bpmn-elements/presets/Pool/Pool.d.ts +2 -2
- package/lib/components/mini-map/index.d.ts +2 -0
- package/lib/components/mini-map/index.js +10 -0
- package/lib/index.css +1 -278
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/style/index.css +1 -278
- package/lib/style/raw.d.ts +1 -1
- package/lib/style/raw.js +1 -1
- package/lib/tools/label/Label.d.ts +4 -0
- package/lib/tools/label/Label.js +75 -31
- package/lib/tools/label/LabelModel.js +1 -0
- package/lib/tools/label/index.d.ts +1 -0
- package/lib/tools/label/index.js +46 -2
- package/lib/tools/proximity-connect/index.d.ts +42 -0
- package/lib/tools/proximity-connect/index.js +340 -0
- package/package.json +3 -3
- package/stats.html +1 -1
- package/es/index.less +0 -1
- package/es/style/index.less +0 -327
- package/lib/index.less +0 -1
- package/lib/style/index.less +0 -327
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { twoPointDistance, } from '@logicflow/core';
|
|
13
|
+
import { assign, isEmpty, isEqual, isNil, isFinite, reduce } from 'lodash-es';
|
|
14
|
+
var ProximityConnect = /** @class */ (function () {
|
|
15
|
+
function ProximityConnect(_a) {
|
|
16
|
+
var lf = _a.lf, options = _a.options;
|
|
17
|
+
this.enable = true;
|
|
18
|
+
this.currentDistance = Infinity; // 当前间距
|
|
19
|
+
this.thresholdDistance = 100; // 节点-节点连接距离阈值
|
|
20
|
+
this.reverseDirection = false; // 节点-节点连线方向,默认是拖拽节点连向最近节点
|
|
21
|
+
this.virtualEdgeStyle = {
|
|
22
|
+
strokeDasharray: '10,10',
|
|
23
|
+
stroke: '#acacac',
|
|
24
|
+
}; // 虚拟边样式
|
|
25
|
+
this.lf = lf;
|
|
26
|
+
assign(this, options);
|
|
27
|
+
}
|
|
28
|
+
ProximityConnect.prototype.render = function () {
|
|
29
|
+
this.addEventListeners();
|
|
30
|
+
};
|
|
31
|
+
// 增加节点拖拽和锚点拖拽的事件监听
|
|
32
|
+
ProximityConnect.prototype.addEventListeners = function () {
|
|
33
|
+
var _this = this;
|
|
34
|
+
// 节点开始拖拽事件
|
|
35
|
+
this.lf.graphModel.eventCenter.on('node:dragstart', function (_a) {
|
|
36
|
+
var data = _a.data;
|
|
37
|
+
if (!_this.enable)
|
|
38
|
+
return;
|
|
39
|
+
var graphModel = _this.lf.graphModel;
|
|
40
|
+
var id = data.id;
|
|
41
|
+
_this.currentNode = graphModel.getNodeModelById(id);
|
|
42
|
+
});
|
|
43
|
+
// 节点拖拽事件
|
|
44
|
+
this.lf.graphModel.eventCenter.on('node:drag', function () {
|
|
45
|
+
_this.handleNodeDrag();
|
|
46
|
+
});
|
|
47
|
+
// 锚点开始拖拽事件
|
|
48
|
+
this.lf.graphModel.eventCenter.on('anchor:dragstart', function (_a) {
|
|
49
|
+
var data = _a.data, nodeModel = _a.nodeModel;
|
|
50
|
+
if (!_this.enable)
|
|
51
|
+
return;
|
|
52
|
+
_this.currentNode = nodeModel;
|
|
53
|
+
_this.currentAnchor = data;
|
|
54
|
+
});
|
|
55
|
+
// 锚点拖拽事件
|
|
56
|
+
this.lf.graphModel.eventCenter.on('anchor:drag', function (_a) {
|
|
57
|
+
var _b = _a.e, clientX = _b.clientX, clientY = _b.clientY;
|
|
58
|
+
if (!_this.enable)
|
|
59
|
+
return;
|
|
60
|
+
_this.handleAnchorDrag(clientX, clientY);
|
|
61
|
+
});
|
|
62
|
+
// 节点、锚点拖拽结束事件
|
|
63
|
+
this.lf.graphModel.eventCenter.on('node:drop,anchor:dragend', function () {
|
|
64
|
+
if (!_this.enable)
|
|
65
|
+
return;
|
|
66
|
+
_this.handleDrop();
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
// 节点拖拽动作
|
|
70
|
+
ProximityConnect.prototype.handleNodeDrag = function () {
|
|
71
|
+
/**
|
|
72
|
+
* 主要做几件事情
|
|
73
|
+
* 判断当前是否有虚拟连线,有的话判断两点距离是否超过阈值,超过的话删除连线
|
|
74
|
+
* 遍历画布上的所有节点,找到距离最近的节点,获取其所有锚点数据
|
|
75
|
+
* 判断每个锚点与当前选中节点的所有锚点之间的距离,找到路路径最短的两个点时,把当前节点、当前锚点当前最短记录记录下来,作为当前最近数据
|
|
76
|
+
* 判断当前最短距离是否小于阈值
|
|
77
|
+
* 如果是 就创建虚拟边
|
|
78
|
+
*/
|
|
79
|
+
var nodes = this.lf.graphModel.nodes;
|
|
80
|
+
if (!isNil(this.virtualEdge)) {
|
|
81
|
+
var _a = this.virtualEdge, startPoint = _a.startPoint, endPoint = _a.endPoint, id = _a.id;
|
|
82
|
+
var curDistance = twoPointDistance(startPoint, endPoint);
|
|
83
|
+
if (curDistance > this.thresholdDistance) {
|
|
84
|
+
this.lf.deleteEdge(id);
|
|
85
|
+
this.virtualEdge = undefined;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (this.currentNode) {
|
|
89
|
+
this.findClosestAnchorOfNode(this.currentNode, nodes);
|
|
90
|
+
}
|
|
91
|
+
if (this.currentDistance < this.thresholdDistance) {
|
|
92
|
+
this.addVirtualEdge();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
// 节点放下
|
|
96
|
+
ProximityConnect.prototype.handleDrop = function () {
|
|
97
|
+
this.addActualEdge();
|
|
98
|
+
this.resetData();
|
|
99
|
+
};
|
|
100
|
+
// 锚点拖拽动作
|
|
101
|
+
ProximityConnect.prototype.handleAnchorDrag = function (clientX, clientY) {
|
|
102
|
+
// 获取当前点在画布上的位置
|
|
103
|
+
var graphModel = this.lf.graphModel;
|
|
104
|
+
var _a = graphModel.getPointByClient({
|
|
105
|
+
x: clientX,
|
|
106
|
+
y: clientY,
|
|
107
|
+
}).canvasOverlayPosition, x = _a.x, y = _a.y;
|
|
108
|
+
if (isNil(x) || isNil(y))
|
|
109
|
+
return;
|
|
110
|
+
var currentPoint = { x: x, y: y };
|
|
111
|
+
var nodes = graphModel.nodes;
|
|
112
|
+
// 判断当前是否有虚拟连线,有的话判断两点距离是否超过阈值,超过的话删除连线
|
|
113
|
+
if (!isNil(this.virtualEdge)) {
|
|
114
|
+
var _b = this.virtualEdge, endPoint = _b.endPoint, id = _b.id;
|
|
115
|
+
var curDistance = twoPointDistance(currentPoint, endPoint);
|
|
116
|
+
if (curDistance > this.thresholdDistance) {
|
|
117
|
+
this.lf.deleteEdge(id);
|
|
118
|
+
this.virtualEdge = undefined;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// 记录最近点的信息
|
|
122
|
+
this.findClosestAnchorOfAnchor(currentPoint, nodes);
|
|
123
|
+
if (this.currentDistance < this.thresholdDistance) {
|
|
124
|
+
this.addVirtualEdge();
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
// 节点→节点 找最近的节点和锚点
|
|
128
|
+
ProximityConnect.prototype.findClosestAnchorOfNode = function (draggingNode, allNodes) {
|
|
129
|
+
var _this = this;
|
|
130
|
+
if (isNil(draggingNode) || isEmpty(draggingNode))
|
|
131
|
+
return;
|
|
132
|
+
var _a = draggingNode.anchors, draggingAnchors = _a === void 0 ? [] : _a, id = draggingNode.id;
|
|
133
|
+
var distance;
|
|
134
|
+
var preConnectAnchor;
|
|
135
|
+
var closestAnchor;
|
|
136
|
+
var closestNode;
|
|
137
|
+
allNodes.forEach(function (node) {
|
|
138
|
+
if (isEqual(node.id, id))
|
|
139
|
+
return;
|
|
140
|
+
var _a = node.anchors, anchors = _a === void 0 ? [] : _a;
|
|
141
|
+
// 遍历所有节点,找离当前拖拽节点最近的可连接节点和锚点
|
|
142
|
+
anchors.forEach(function (anchor) {
|
|
143
|
+
// 找距离最近的两个锚点
|
|
144
|
+
draggingAnchors.forEach(function (draggingAnchor) {
|
|
145
|
+
// 判断拖拽点锚点和当前锚点是否可连线
|
|
146
|
+
var anchorAllowConnect = _this.anchorAllowConnect(node, anchor, draggingAnchor);
|
|
147
|
+
if (!anchorAllowConnect)
|
|
148
|
+
return;
|
|
149
|
+
// 获取两个锚点之间的距离
|
|
150
|
+
var curDistance = twoPointDistance(draggingAnchor, anchor);
|
|
151
|
+
if (!distance || curDistance < distance) {
|
|
152
|
+
// 如果是第一条数据,或者当前这对锚点距离更短,就替换数据
|
|
153
|
+
distance = curDistance;
|
|
154
|
+
preConnectAnchor = draggingAnchor;
|
|
155
|
+
closestAnchor = anchor;
|
|
156
|
+
closestNode = node;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
this.currentDistance = distance;
|
|
162
|
+
this.currentAnchor = preConnectAnchor;
|
|
163
|
+
this.closestAnchor = closestAnchor;
|
|
164
|
+
this.closestNode = closestNode;
|
|
165
|
+
};
|
|
166
|
+
// 锚点→节点 找最近的锚点
|
|
167
|
+
ProximityConnect.prototype.findClosestAnchorOfAnchor = function (draggingPoint, allNodes) {
|
|
168
|
+
var _this = this;
|
|
169
|
+
if (isNil(draggingPoint))
|
|
170
|
+
return;
|
|
171
|
+
var distance;
|
|
172
|
+
var closestAnchor;
|
|
173
|
+
var closestNode;
|
|
174
|
+
var _a = this, currentNode = _a.currentNode, currentAnchor = _a.currentAnchor;
|
|
175
|
+
allNodes.forEach(function (node) {
|
|
176
|
+
if (!currentNode)
|
|
177
|
+
return;
|
|
178
|
+
var _a = node.anchors, anchors = _a === void 0 ? [] : _a;
|
|
179
|
+
// 遍历所有节点,找离当前拖拽节点最近的可连接节点和锚点
|
|
180
|
+
anchors.forEach(function (anchor) {
|
|
181
|
+
var _a;
|
|
182
|
+
if (isEqual((_a = _this.currentAnchor) === null || _a === void 0 ? void 0 : _a.id, anchor.id))
|
|
183
|
+
return;
|
|
184
|
+
// 判断拖拽点锚点和当前锚点是否可连线
|
|
185
|
+
var anchorAllowConnect = _this.anchorAllowConnect(node, anchor, currentAnchor);
|
|
186
|
+
if (!anchorAllowConnect)
|
|
187
|
+
return;
|
|
188
|
+
// 获取两个锚点之间的距离
|
|
189
|
+
var curDistance = twoPointDistance(draggingPoint, anchor);
|
|
190
|
+
if (!distance || curDistance < distance) {
|
|
191
|
+
// 如果是第一条数据,或者当前这对锚点距离更短,就替换数据
|
|
192
|
+
distance = curDistance;
|
|
193
|
+
closestAnchor = anchor;
|
|
194
|
+
closestNode = node;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
this.currentDistance = distance;
|
|
199
|
+
this.closestAnchor = closestAnchor;
|
|
200
|
+
this.closestNode = closestNode;
|
|
201
|
+
};
|
|
202
|
+
// 判断锚点是否允许连线
|
|
203
|
+
ProximityConnect.prototype.anchorAllowConnect = function (node, anchor, draggingAnchor) {
|
|
204
|
+
var currentNode = this.currentNode;
|
|
205
|
+
if (!currentNode)
|
|
206
|
+
return;
|
|
207
|
+
// 判断起点是否可连接
|
|
208
|
+
var sourceValidResult = (this.reverseDirection
|
|
209
|
+
? node.isAllowConnectedAsSource(currentNode, anchor, draggingAnchor)
|
|
210
|
+
: currentNode.isAllowConnectedAsSource(node, draggingAnchor, anchor)).isAllPass;
|
|
211
|
+
// 判断终点是否可连接
|
|
212
|
+
var targetValidResult = (this.reverseDirection
|
|
213
|
+
? currentNode.isAllowConnectedAsTarget(node, anchor, draggingAnchor)
|
|
214
|
+
: node.isAllowConnectedAsTarget(currentNode, draggingAnchor, anchor)).isAllPass;
|
|
215
|
+
return sourceValidResult && targetValidResult;
|
|
216
|
+
};
|
|
217
|
+
// 判断是否应该删除虚拟边
|
|
218
|
+
ProximityConnect.prototype.sameEdgeIsExist = function (edge) {
|
|
219
|
+
if (isNil(this.closestNode) ||
|
|
220
|
+
isNil(this.currentNode) ||
|
|
221
|
+
isNil(this.closestAnchor) ||
|
|
222
|
+
isNil(this.currentAnchor))
|
|
223
|
+
return false;
|
|
224
|
+
if (isNil(edge))
|
|
225
|
+
return false;
|
|
226
|
+
var _a = this, closestNodeId = _a.closestNode.id, currentNodeId = _a.currentNode.id, closestAnchorId = _a.closestAnchor.id, currentAnchorId = _a.currentAnchor.id, reverseDirection = _a.reverseDirection;
|
|
227
|
+
var sourceNodeId = edge.sourceNodeId, targetNodeId = edge.targetNodeId, sourceAnchorId = edge.sourceAnchorId, targetAnchorId = edge.targetAnchorId;
|
|
228
|
+
var isExist = reverseDirection
|
|
229
|
+
? isEqual(closestNodeId, sourceNodeId) &&
|
|
230
|
+
isEqual(currentNodeId, targetNodeId) &&
|
|
231
|
+
isEqual(closestAnchorId, sourceAnchorId) &&
|
|
232
|
+
isEqual(currentAnchorId, targetAnchorId)
|
|
233
|
+
: isEqual(currentNodeId, sourceNodeId) &&
|
|
234
|
+
isEqual(closestNodeId, targetNodeId) &&
|
|
235
|
+
isEqual(currentAnchorId, sourceAnchorId) &&
|
|
236
|
+
isEqual(closestAnchorId, targetAnchorId);
|
|
237
|
+
return isExist;
|
|
238
|
+
};
|
|
239
|
+
// 增加虚拟边
|
|
240
|
+
ProximityConnect.prototype.addVirtualEdge = function () {
|
|
241
|
+
var _this = this;
|
|
242
|
+
var edges = this.lf.graphModel.edges;
|
|
243
|
+
// 判断当前是否已存在一条同样配置的真实边
|
|
244
|
+
var actualEdgeIsExist = reduce(edges, function (result, edge) {
|
|
245
|
+
if (edge.virtual)
|
|
246
|
+
return result;
|
|
247
|
+
return result || _this.sameEdgeIsExist(edge);
|
|
248
|
+
}, false);
|
|
249
|
+
// 如果有真实边就不重复创建边了
|
|
250
|
+
if (actualEdgeIsExist)
|
|
251
|
+
return;
|
|
252
|
+
// 判断当前是否有虚拟边
|
|
253
|
+
// 如果当前已有虚拟边,判断当前的节点和锚点信息与虚拟边的信息是否一致
|
|
254
|
+
if (!isNil(this.virtualEdge)) {
|
|
255
|
+
var edgeId = this.virtualEdge.id;
|
|
256
|
+
// 信息一致不做处理
|
|
257
|
+
if (this.sameEdgeIsExist(this.virtualEdge))
|
|
258
|
+
return;
|
|
259
|
+
// 不一致就删除老边
|
|
260
|
+
this.lf.deleteEdge(edgeId);
|
|
261
|
+
}
|
|
262
|
+
// 开始创建虚拟边
|
|
263
|
+
var _a = this, reverseDirection = _a.reverseDirection, currentNode = _a.currentNode, closestNode = _a.closestNode, currentAnchor = _a.currentAnchor, closestAnchor = _a.closestAnchor;
|
|
264
|
+
if (isEmpty(currentNode) || isEmpty(closestNode))
|
|
265
|
+
return;
|
|
266
|
+
var properties = {
|
|
267
|
+
style: this.virtualEdgeStyle,
|
|
268
|
+
};
|
|
269
|
+
this.virtualEdge = this.lf.addEdge(reverseDirection
|
|
270
|
+
? {
|
|
271
|
+
sourceNodeId: closestNode === null || closestNode === void 0 ? void 0 : closestNode.id,
|
|
272
|
+
targetNodeId: currentNode === null || currentNode === void 0 ? void 0 : currentNode.id,
|
|
273
|
+
sourceAnchorId: closestAnchor === null || closestAnchor === void 0 ? void 0 : closestAnchor.id,
|
|
274
|
+
targetAnchorId: currentAnchor === null || currentAnchor === void 0 ? void 0 : currentAnchor.id,
|
|
275
|
+
properties: properties,
|
|
276
|
+
}
|
|
277
|
+
: {
|
|
278
|
+
sourceNodeId: currentNode === null || currentNode === void 0 ? void 0 : currentNode.id,
|
|
279
|
+
targetNodeId: closestNode === null || closestNode === void 0 ? void 0 : closestNode.id,
|
|
280
|
+
sourceAnchorId: currentAnchor === null || currentAnchor === void 0 ? void 0 : currentAnchor.id,
|
|
281
|
+
targetAnchorId: closestAnchor === null || closestAnchor === void 0 ? void 0 : closestAnchor.id,
|
|
282
|
+
properties: properties,
|
|
283
|
+
});
|
|
284
|
+
this.virtualEdge.virtual = true;
|
|
285
|
+
};
|
|
286
|
+
// 增加实体边
|
|
287
|
+
ProximityConnect.prototype.addActualEdge = function () {
|
|
288
|
+
if (isNil(this.virtualEdge))
|
|
289
|
+
return;
|
|
290
|
+
var _a = this.virtualEdge, type = _a.type, sourceNodeId = _a.sourceNodeId, targetNodeId = _a.targetNodeId, sourceAnchorId = _a.sourceAnchorId, targetAnchorId = _a.targetAnchorId, startPoint = _a.startPoint, endPoint = _a.endPoint, pointsList = _a.pointsList;
|
|
291
|
+
this.lf.addEdge({
|
|
292
|
+
type: type,
|
|
293
|
+
sourceNodeId: sourceNodeId,
|
|
294
|
+
targetNodeId: targetNodeId,
|
|
295
|
+
sourceAnchorId: sourceAnchorId,
|
|
296
|
+
targetAnchorId: targetAnchorId,
|
|
297
|
+
startPoint: startPoint,
|
|
298
|
+
endPoint: endPoint,
|
|
299
|
+
pointsList: pointsList,
|
|
300
|
+
});
|
|
301
|
+
this.lf.deleteEdge(this.virtualEdge.id);
|
|
302
|
+
};
|
|
303
|
+
// 设置虚拟边样式
|
|
304
|
+
ProximityConnect.prototype.setVirtualEdgeStyle = function (value) {
|
|
305
|
+
this.virtualEdgeStyle = __assign(__assign({}, this.virtualEdgeStyle), value);
|
|
306
|
+
};
|
|
307
|
+
// 设置连线阈值
|
|
308
|
+
ProximityConnect.prototype.setThresholdDistance = function (distance) {
|
|
309
|
+
console.log('distance', distance);
|
|
310
|
+
if (!isFinite(distance))
|
|
311
|
+
return;
|
|
312
|
+
this.thresholdDistance = distance;
|
|
313
|
+
};
|
|
314
|
+
// 设置连线方向
|
|
315
|
+
ProximityConnect.prototype.setReverseDirection = function (value) {
|
|
316
|
+
this.reverseDirection = value;
|
|
317
|
+
};
|
|
318
|
+
// 设置插件开关状态
|
|
319
|
+
ProximityConnect.prototype.setEnable = function (enable) {
|
|
320
|
+
this.enable = enable;
|
|
321
|
+
if (!enable) {
|
|
322
|
+
this.resetData();
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
// 重置数据
|
|
326
|
+
ProximityConnect.prototype.resetData = function () {
|
|
327
|
+
this.closestNode = undefined;
|
|
328
|
+
this.currentDistance = Infinity;
|
|
329
|
+
this.currentNode = undefined;
|
|
330
|
+
this.currentAnchor = undefined;
|
|
331
|
+
this.closestAnchor = undefined;
|
|
332
|
+
this.virtualEdge = undefined;
|
|
333
|
+
};
|
|
334
|
+
ProximityConnect.pluginName = 'proximityConnect';
|
|
335
|
+
return ProximityConnect;
|
|
336
|
+
}());
|
|
337
|
+
export { ProximityConnect };
|
|
@@ -24,8 +24,8 @@ export declare class HorizontalLaneModel extends GroupNodeModel {
|
|
|
24
24
|
color?: string | undefined;
|
|
25
25
|
fontSize: number;
|
|
26
26
|
lineHeight?: number | undefined;
|
|
27
|
-
textAnchor?: "
|
|
28
|
-
dominantBaseline?: "middle" | "auto" | "text-bottom" | "alphabetic" | "ideographic" | "
|
|
27
|
+
textAnchor?: "middle" | "start" | "end" | undefined;
|
|
28
|
+
dominantBaseline?: "middle" | "central" | "auto" | "text-bottom" | "alphabetic" | "ideographic" | "mathematical" | "hanging" | "text-top" | undefined;
|
|
29
29
|
};
|
|
30
30
|
foldGroup(isFolded: boolean): void;
|
|
31
31
|
resizePool(resizeId?: string, newNodeSize?: {
|
|
@@ -151,6 +151,7 @@ export declare class MiniMap {
|
|
|
151
151
|
*/
|
|
152
152
|
private disabledPlugins;
|
|
153
153
|
constructor({ lf, LogicFlow, options }: LogicFlow.IExtensionProps);
|
|
154
|
+
onGraphResize: () => void;
|
|
154
155
|
render: (_: LogicFlow, container: HTMLElement) => void;
|
|
155
156
|
/**
|
|
156
157
|
* 显示小地图
|
|
@@ -232,5 +233,6 @@ export declare class MiniMap {
|
|
|
232
233
|
* 点击小地图中非预览视窗的区域时,移动主画布视口聚焦于点击位置
|
|
233
234
|
*/
|
|
234
235
|
private mapClick;
|
|
236
|
+
destroy(): void;
|
|
235
237
|
}
|
|
236
238
|
export default MiniMap;
|
|
@@ -71,6 +71,12 @@ var MiniMap = /** @class */ (function () {
|
|
|
71
71
|
* 小地图的logicFlow实例需要禁用的插件
|
|
72
72
|
*/
|
|
73
73
|
this.disabledPlugins = ['miniMap', 'control', 'selectionSelect'];
|
|
74
|
+
this.onGraphResize = function () {
|
|
75
|
+
_this.updateViewPortBounds();
|
|
76
|
+
if (_this.isShow) {
|
|
77
|
+
_this.updateViewPort();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
74
80
|
this.render = function (_, container) {
|
|
75
81
|
_this.container = container;
|
|
76
82
|
_this.lf.on('history:change', function () {
|
|
@@ -230,6 +236,7 @@ var MiniMap = /** @class */ (function () {
|
|
|
230
236
|
this.elementAreaBounds = boundsInit;
|
|
231
237
|
this.viewPortBounds = boundsInit;
|
|
232
238
|
this.initMiniMap();
|
|
239
|
+
lf.on('graph:resize', this.onGraphResize);
|
|
233
240
|
}
|
|
234
241
|
/**
|
|
235
242
|
* 初始化小地图的配置
|
|
@@ -511,6 +518,9 @@ var MiniMap = /** @class */ (function () {
|
|
|
511
518
|
});
|
|
512
519
|
this.viewport = div;
|
|
513
520
|
};
|
|
521
|
+
MiniMap.prototype.destroy = function () {
|
|
522
|
+
this.lf.off('graph:resize', this.onGraphResize);
|
|
523
|
+
};
|
|
514
524
|
MiniMap.pluginName = 'miniMap';
|
|
515
525
|
return MiniMap;
|
|
516
526
|
}());
|