New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to ungroup objects #489
Comments
ungrouping is just moving the layers of the group to the parent of the group, right? I don't think you need a specific API for it |
I guess its nice because of a few things
Right now I have to remove the parent for each layer in the group and then reattach the containing parent to the layers (bc of this bug #486). I then have to be careful that objects aren’t repositioned because the frames need to be different. Lastly, I then have to clean up the leftover group and remove the parent. (Which I assume delete’s the group object?) |
The bug will be fixed soon so it will be easier :) So it would look like this: const parent = group.parent
group.layers.forEach(l => {
l.frame = frame.changeBasis({ from: group, to: parent })
l.parent = parent
})
group.remove() I'm trying to keep the API surface to a minimum: if you can do it with the existing API, it's not likely that I'll add a helper function in the core API. That's being said, we could start to create another module with those kind of helpers. There are much easier to contribute to because you don't need any knowledge about the internal API. |
Yeah its pretty verbose. Adding a new module with those helpers would be cool! Maybe another module for some UI stuff too? I'll note that this could be a good candidate for a different module. Also, didn't know about the |
I wrote a bit about what should or shoudn't go in the API here: https://github.com/BohemianCoding/SketchAPI/blob/70ab0df427f3a3c277fd7810b0cae8075535b16d/docs/philosophy.md I'll close this issue now but let's start to think about some helpers that could be included in a separate library (a bit like lodash) |
It is pretty easy to drop down into the internal API to ungroup an object but it would be nice if the JS API properly supported it.
The text was updated successfully, but these errors were encountered: