How to identify the type of a selected object?

前端 未结 4 1317
故里飘歌
故里飘歌 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:10

    I solved this issue using following code::

      if(canvas.getActiveObject().get('type')==="text")
            {
                //Display text panel
                console.log('text panel Displayed');
                $("#Image_left_panel").css("display", "none");
                $("#shape_left_panel").css("display", "none");
                //$("#left_panel").css("display", "block");
            }
            else if(canvas.getActiveObject().get('type')==="Image")
            {
                //Display Image Panel
                console.log('Image Panel Displayed');
                $("#Image_left_panel").css("display", "block");
                $("#shape_left_panel").css("display", "none");
                $("#left_panel").css("display", "none");
            }
            else
            {
    
            }
    
    
            });
    

提交回复
热议问题