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
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.