How to identify the type of a selected object?

前端 未结 4 1315
故里飘歌
故里飘歌 2021-02-12 11:13

I am placing Text, Image and Shapes on canvas using Fabric.js. I have made Three different Edit-Panels for all three. When user select text I want to show text panel. like wise

4条回答
  •  失恋的感觉
    2021-02-12 12:16

    canvas.getActiveObject().get('type') as simmi simmi said is correct. You can also listen to events:

    function onObjectSelected(e) {
      console.log(e.target.get('type'));
    }
    canvas.on('object:selected', onObjectSelected);
    

提交回复
热议问题