我正在尝试扩展一组形状的点击区域,但组上似乎没有 hitFunc 属性。
var patternControl = new Konva.Group();
patternControl.hitFunc(function(context) {
context.beginPath();
context.arc(0, 0, outerRadius + patternWidth, 0, Math.PI * 2, true);
context.fillStrokeShape(this);
});
有什么方法可以将自定义命中功能应用于组?
只有形状可用于命中检测。作为一种解决方法,您可以禁用所有形状的命中shape.listeting(false)
,然后将“假”形状添加到将用作命中区域的组中:
var patternControl = new Konva.Group();
var hitShape = new Konva.Shape({
// make it transparent, so it is not visible
fill: 'rgba(0,0,0,0)',
hitFunc: (context, shape) => {
context.beginPath();
context.arc(0, 0, outerRadius + patternWidth, 0, Math.PI * 2, true);
context.fillStrokeShape(shape);
}
});
patternControl.add(hitShape);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句