Reputation: 34556
I can successfully change the z-index of shapes and groups, but I have so far not been able to do this for layers.
Instead, they seem doomed to stay in the stack order that I added them to the stage.
I've tried:
layer.moveToTop();
layer.setZIndex(100);
...but no change (even though layer nodes do inherit these methods). What am I missing here?
Thanks in advance
Upvotes: 3
Views: 3499
Reputation: 2809
I've found that the layer needs to be manually redrawn before the changes take effect.
layer.draw();
As an aside, it's also worth noting that Kinetic JS does not actually honor the z-index values that you provide. Internally, whenever setZIndex() is called, it seems to reassign z-index values from zero up to N-1, where N is the number of objects. I believe that this line of code in the Kinetic JS source on GitHub is what does the reindexing ...
this.parent._setChildrenIndices();
Upvotes: 1