You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a π reaction to this issue if you would like to see this feature added. Do not add +1 comments β They will be deleted.
Right now there's no easy way to access a child of a parent copied with copyGraph.
// right armletupperArm=newZdog.Shape({//...});letforeArm=newZdog.Shape({addTo: upperArm,// ...});// handnewZdog.Shape({addTo: foreArm,color: '#C25',// ...});// left armupperArm.copyGraph();// How do set the left hand to a different color?
With the name option, you could access children via an Object property.
// right armletupperArm=newZdog.Shape({//...});newZdog.Shape({addTo: upperArm,name: 'foreArm',// accessible as parent.foreArm// ...});// handnewZdog.Shape({addTo: upperArm.foreArm,name: 'hand',// accessible as parent.handcolor: '#C25',// ...});// left armletleftArm=upperArm.copyGraph();// set left hand to different colorleftArm.foreArm.hand.color='#EA0';
The text was updated successfully, but these errors were encountered:
It could be done in the create function of the Anchor class, so every shape inherits it.
2. Give direct access to a child with a parent.childName syntax
You could attach a property that points to the child in the parent instance for sure, but then you have to handle name collisions (naming an item "rotate" for example). This may force to output warnings to users telling certain names are restricted when they use it (which I never really liked as a developer experience).
If we don't want to worry about name collisions, I would personally opt for a getChild("my-child-name") property that loops throughout the children property looking for an item which has the correct name.
Maybe I'm not aware of an existing way to handle dynamic properties accessors without name collisions ?
Hi @desandro !
I discovered Zdog recently, and I like it a lot, it's a cool project. You made a very good job, thank's a lot.
I would appreciate to be able to set a ChildName on the graphical objects. And, if you could add a "find" function on the main object to retrieve a child by its name, it would be really great.
Thank's a lot.
Add a π reaction to this issue if you would like to see this feature added. Do not add +1 comments β They will be deleted.
Right now there's no easy way to access a child of a parent copied with
copyGraph
.With the
name
option, you could access children via an Object property.The text was updated successfully, but these errors were encountered: