Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to select handles for zoom and rotation #4

Open
Cenmingyang opened this issue Feb 13, 2025 · 0 comments
Open

Unable to select handles for zoom and rotation #4

Cenmingyang opened this issue Feb 13, 2025 · 0 comments

Comments

@Cenmingyang
Copy link

addText(content = "Hello, world!", options = {}) {

  this.viewer.setMouseNavEnabled(false);
  // 获取 fabric canvas 实例
  const canvas = this.overlay.fabricCanvas();

  // 定义默认的文本配置,文本将显示在画布中央
  const defaultOptions = {
    left: canvas.getWidth() / 2,
    top: canvas.getHeight() / 2,
    fill: 'black',
    fontSize: 20,
    fontWeight: 'normal',
    selectable: true,       // 允许选中以拖动
    lockScalingX: false,    // 允许水平方向缩放
    lockScalingY: false,    // 允许垂直方向缩放
    lockRotation: false,    // 允许旋转
    hasControls: true,      // 显示控制点(缩放、旋转)
  };

  // 合并用户传入的配置项
  const config = { ...defaultOptions, ...options };

  // 创建 Fabric 文本对象(确保已引入 fabric 库)
  const textObj = new Text(content, config);

  // 将文本对象添加到 canvas 中
  canvas.add(textObj);
  canvas.renderAll(); // 刷新画布
}

Image

Unable to select handles for zoom and rotation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant