1
votes

In the CreateJS documentation (https://www.createjs.com/docs/easeljs/classes/Container.html#method_sortChildren) they describe how to use the sortChildren function to sort a child list. I can't realy undrestand how to use it in my Angular6 project. Here is what I try to do but it doesn't work... Any idea ? this.elementsLayer.sortChildren((a:any,b:any) => { console.log(a.zIndex) if (a.zIndex < b.zIndex) return -1; if (a.zIndex > b.zIndex) return 1; return 0; })

1

1 Answers

1
votes

I think you need to treat it as a higher-order function.

const zSort = (a, b) =>
    {
       console.log(a.zIndex)
       if (a.zIndex < b.zIndex) return -1;
       if (a.zIndex > b.zIndex) return 1;
       return 0;
    }

this.elementsLayer.sortChildren(zSort);