scalable-rect-node.js
1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* @Date: 2025-03-17 23:23:33
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-03-17 23:35:02
* @FilePath: /logic-flow2/src/views/api/scalable-rect-node.js
* @Description: 文件描述
*/
import { RectResize } from "@logicflow/extension";
class CustomNode extends RectResize.view {
}
class ScalableRectNode extends RectResize.model {
initNodeData(data) {
super.initNodeData(data);
this.width = 80;
this.height = 40;
this.maxWidth = 300;
this.maxHeight = 300;
this.text.draggable = true;
}
// setAttributes() {
// const size = this.properties.scale || 1;
// this.width = 100 * size;
// this.height = 80 * size;
// }
getDefaultAnchor() {
const { width, height, x, y, id } = this;
return [
{ x: x - width / 2, y, id: `${id}_0` },
{ x: x + width / 2, y, id: `${id}_1` },
{ x, y: y - height / 2, id: `${id}_2` },
{ x, y: y + height / 2, id: `${id}_3` },
];
}
}
export default {
type: 'scalable-rect',
view: CustomNode,
model: ScalableRectNode,
};