How to check if group has a children or not in kineticjs?

by tressie.damore , in category: Javascript , 3 months ago

How to check if group has a children or not in kineticjs?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by ryan.murray , 3 months ago

@tressie.damore 

You can check if a KineticJS group has children by accessing the children property of the group and checking its length. If the length is greater than 0, then the group has children. Here's a code example:

1
2
3
4
5
6
// Assuming group is your KineticJS group
if (group.children.length > 0) {
    console.log("Group has children");
} else {
    console.log("Group does not have children");
}


This code snippet will log to the console if the group has children or not.