mathieudutour
So, is the relationship between Layer
and MSLayer
similar to the relationship between Group
and MSLayerGroup
, where the former one is from JS API while the latter one is native?
I ask this because I tried to use new Group
instead of MSLayerGroup
before as below:
var Group = require('sketch/dom').Group;
var newGroup = new Group({
name: layerName,
layers: [layer],
parent: group
});`
newGroup.adjustToFit();
but encountered TypeError: newGroup.name is not a function. (In \'newGroup.name()\', \'newGroup.name\' is "background panel")'
when I accessed name of newGroup and didn't know why.
I ended up using code below because I need to access newGroup's name. but I still cannot understand exact differences between native object and the other.
Do you mean that Sketch update may change native objects while those objects in JS API will not be influenced?
var newGroup = MSLayerGroup.new();
newGroup.setName(layerName);
newGroup.addLayers([layer]);
newGroup.resizeToFitChildrenWithOption(0);
group.addLayers([newGroup]);
group.resizeToFitChildrenWithOption(0);
Thanks a lot for your patience and reply!
Winnie