scalable-rect-node.js 1.04 KB
/*
 * @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,
};