jonobr1 / two.js

A renderer agnostic two-dimensional drawing api for the web.
https://two.js.org
MIT License
8.29k stars 454 forks source link

Collection made generic & type to Group.children #655

Closed alper-batioglu closed 2 years ago

alper-batioglu commented 2 years ago

Group.children if I am not mistaken is the collection of items added by the Group.Add method. So they are TwoElements. With this assumption I made Collection generic. (with default of any in order to prevent affecting other usages) And also defined Children type as a collection of TwoElements. And also Group.children as Children.

this made usages possible like, this.root.children.forEach(child => this.root.position.blablabla

I am still thinking of export class Children extends Collection<Shape> ... but children is filled by Add and it accepts TwoElement; so I think i will stick with that.

jonobr1 commented 2 years ago

Thank you for the improvements!!