如何更改变压器旋转图标的位置

问题描述 投票:0回答:1

我已经开始反应了。而且我正在尝试使用Transfomer。

目前,旋转处理程序位于顶部中心位置,我想将其放置在底部中心位置,左侧或另一侧。我该怎么办?

https://konvajs.org/docs/select_and_transform/Transformer_Styling.html

konvajs transformer react-konva
1个回答
0
投票

当前无法使用[email protected] API直接进行(Konva)。但是您可以通过在旋转的组中放置形状来解决。

const group = new Konva.Group({
  x: stage.width() / 2,
  y: stage.height() / 2,
  rotation: 90
});
layer.add(group);

const shape = new Konva.Rect({
  rotation: -90,
  width: 100,
  height: 50,
  fill: 'green'
});
group.add(shape);

const tr = new Konva.Transformer({
  node: group
})
layer.add(tr);

但是在这种情况下,跟踪形状的绝对位置更加复杂。因为Konva.Transformer将更改组的属性,而不是形状。

https://jsbin.com/peqinuzuqi/1/edit?html,js,output

© www.soinside.com 2019 - 2024. All rights reserved.