Issue
The X
and Y
values of an object don’t match up with the inspector when using boundsInParent
for an object or Group within a Group (on an Artboard).
Steps to reproduce
- Create a rectangle on an artboard and use
boundsInParent
to get thex
andy
coordinates. - Group the rectangle and use
boundsInParent
on the rectangle to get thex
andy
coordinates. - Group the group and use
boundsInParent
on the nested group and the rectangle to get thex
andy
coordinates.
Expected Behavior
The x
and y
values should be 0
on every object and group that is within a group.
Actual Behavior
The x
and y
values are incorrect when nested one level in a Group. I can’t identify where how the values are being calculated. On the third level down, the values are correct. It looks like localCenterPoint
is also affected.
Additional information
Artboard is 120x120
and 1000px
off the x
and y
.
Rectangles are 80x80
and 20px
off the x
and y
.
Rectangle 1
boundsInParent: { x: 20, y: 20, width: 80, height: 80 }
globalBounds: { x: 1020, y: 1020, width: 80, height: 80 }
localBounds: { x: 0, y: 0, width: 80, height: 80 }
topLeftInParent: { x: 20, y: 20 }
localCenterPoint: { x: 40, y: 40 }
----------------
Group 1
boundsInParent: { x: 20, y: 20, width: 80, height: 80 }
globalBounds: { x: 1020, y: 1020, width: 80, height: 80 }
localBounds: { x: 192, y: 418, width: 80, height: 80 }
topLeftInParent: { x: 20, y: 20 }
localCenterPoint: { x: 232, y: 458 }
----------------
Rectangle 2
boundsInParent: { x: 192, y: 418, width: 80, height: 80 }
globalBounds: { x: 1020, y: 1020, width: 80, height: 80 }
localBounds: { x: 0, y: 0, width: 80, height: 80 }
topLeftInParent: { x: 192, y: 418 }
localCenterPoint: { x: 40, y: 40 }
----------------
Group 2
boundsInParent: { x: 192, y: 418, width: 80, height: 80 }
globalBounds: { x: 1020, y: 1020, width: 80, height: 80 }
localBounds: { x: 0, y: 0, width: 80, height: 80 }
topLeftInParent: { x: 192, y: 418 }
localCenterPoint: { x: 40, y: 40 }
----------------
Rectangle 3
boundsInParent: { x: 0, y: 0, width: 80, height: 80 }
globalBounds: { x: 1020, y: 1020, width: 80, height: 80 }
localBounds: { x: 0, y: 0, width: 80, height: 80 }
topLeftInParent: { x: 0, y: 0 }
localCenterPoint: { x: 40, y: 40 }
----------------
For completeness, here is the function I’m calling:
function test(selection) {
// Iterate through the selection
selection.items.forEach(function (item) {
console.log(item.name);
console.log('boundsInParent: ', item.boundsInParent);
console.log('globalBounds: ', item.globalBounds);
console.log('localBounds: ', item.localBounds);
console.log('topLeftInParent: ', item.topLeftInParent);
console.log('localCenterPoint: ', item.localCenterPoint);
console.log('----------------');
})
}