FabricJS Catch click on object inside group

后端 未结 7 772
感动是毒
感动是毒 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:30

    This worked for me:

    // create a group
    let group = new fabric.Group([circle, rect], {
        subTargetCheck: true
    });
    
    canvas.on('mouse:down', function (e) {
    // clicked item will be
      console.log(e.subTargets[0])  
    });
    

提交回复
热议问题