Here’s a workaround I came up with to get an object’s responsive resize values. It’s in TypeScript, but should be easy to convert to JavaScript:
private getResponsiveResize(sceneNode: SceneNode): IResponsiveResize {
const delta = 50; // Could be any positive integer
let horizontalAnchor = HorizontalAnchor.center;
let verticalAnchor = VerticalAnchor.center;
const parent = sceneNode.parent;
if (parent != null) {
const previousBounds = sceneNode.boundsInParent;
parent.resize(parent.boundsInParent.width + delta, parent.boundsInParent.height + delta);
const newBounds = sceneNode.boundsInParent;
parent.resize(parent.boundsInParent.width - delta, parent.boundsInParent.height - delta);
if (previousBounds.x === newBounds.x) {
horizontalAnchor = HorizontalAnchor.left;
} else if (previousBounds.x === newBounds.x - delta) {
horizontalAnchor = HorizontalAnchor.right;
}
if (previousBounds.y === newBounds.y) {
verticalAnchor = VerticalAnchor.top;
} else if (previousBounds.y === newBounds.y - delta) {
verticalAnchor = VerticalAnchor.bottom;
}
}
return {
horizontal: horizontalAnchor,
vertical: verticalAnchor
};
}
Type definitions:
export enum HorizontalAnchor {
left = "left",
center = "center",
right = "right"
}
export enum VerticalAnchor {
top = "top",
center = "center",
bottom = "bottom"
}
export interface IResponsiveResize {
horizontal: HorizontalAnchor;
vertical: VerticalAnchor;
}