【发布时间】:2020-10-21 03:24:20
【问题描述】:
我需要创建一个函数,将对象(圆)的属性从可拖动更改为不可拖动。 使用鼠标操作也是理想的,但鼠标用于拖动对象,因此可能需要用鼠标单击它以使其处于活动状态,然后按一个按钮来更改属性。
这是我用来创建圆的代码,新函数需要更改属性draggable。
function addCircle(){
var circle = new Konva.Circle({
x: stage.width() / 2,
y: stage.height() / 2,
radius: 70,
fill: 'red',
stroke: 'black',
strokeWidth: 4,
draggable: true,
id: [ident],
name: 'test',
});
// add the shape to the layer
layer.add(circle);
// add the layer to the stage
stage.add(layer);
};
提前感谢您的帮助。
【问题讨论】:
-
欢迎沃尔特。 shape 属性 draggable(bool) 控制形状是否可拖动。要关闭拖动,请使用 shape.draggable(false),或者在之前禁用拖动时使用 true 启用拖动。
标签: function html5-canvas konvajs