我有以下问题:我正在使用 konvajs 构建一个画布,您可以在其中绘制例如线条。另外,您应该能够移动这些线。直到这里没有问题,为线条赋予可拖动属性一切正常。但是当我移动线条时,我仍然会在开始时画一个点。移动线时如何防止第一个点绘制?
我使用简单的绘图演示开始,所以我有一个绘图功能的 mousedown 事件
stage.on('mousedown touchstart', function (e) {
isPaint = true;
var pos = stage.getPointerPosition();
lastLine = new Konva.Line({
stroke: strokeColor,
strokeWidth: 5,
draggable: true,
lineCap: 'round',
globalCompositeOperation:
mode === 'brush' ? 'source-over' : 'destination-out',
points: [pos.x, pos.y],
});
layer.add(lastLine);
});