Control z-index in Fabric.js

后端 未结 5 1120
独厮守ぢ
独厮守ぢ 2021-02-05 05:35

In fabricjs, I want to create a scene in which the object under the mouse rises to the top of the scene in z-index, then once the mouse leaves that object, it goes back to the z

5条回答
  •  伪装坚强ぢ
    2021-02-05 05:51

    Also make sure you change z-index AFTER adding object to canvas.

    So code will looks like:

    canvas.add(object);
    canvas.moveTo(object, index);
    

    Otherwise fabricjs don`t care about z-indexes you setup.

提交回复
热议问题