FabricJS Catch click on object inside group

后端 未结 7 697
感动是毒
感动是毒 2021-01-17 19:06

I have tried many thing like calculating location, handling with the event we do have in original fabricjs. Does any have done this before?

相关标签:
7条回答
  • 2021-01-17 19:43

    You can add subTarget to the group. The subtarget object will be added inside target event.

    let group = new fabric.Group([circle, rect], {
        subTargetCheck: true
    });
    
    canvas.on('mouse:down', (event) => {
        const { subTargets } = event; // subTargets will include circle object
        .... 
    })
    
    0 讨论(0)
提交回复
热议问题