stretch icon indicating copy to clipboard operation
stretch copied to clipboard

[JS][notice me senpai ◕‿◕] child node position not being set

Open jeebus3000 opened this issue 6 years ago • 0 comments

Hello! I "ported" rust test -- https://github.com/vislyhq/stretch/blob/master/tests/generated/absolute_layout_align_items_center_on_child_only.rs to JS (I believe, I made it correctly)

import { Allocator, Node, AlignSelf, PositionType } from 'stretch-layout';

const allocator = new Allocator();

const node = new Node(allocator, {
    width: 110,
    height: 100,
});

const childNode = new Node(allocator, {
    width: 60,
    height: 40,
    alignSelf: AlignSelf.Center,
    positionType: PositionType.Absolute
});

node.addChild(childNode);

const layout = node.computeLayout(), childLayout = childNode.computeLayout();

console.log(layout.width, layout.height, layout.x, layout.y);
console.log(childLayout.width, childLayout.height, childLayout.x, childLayout.y);

In browser (both FF & Chrome) console I get:

110 100 0 0
60 40 0 0

According to assert_eq!(stretch.layout(node0).unwrap().location.y, 30f32); -- childNode y should be 30 px. I also tried other tests, but no luck either.

jeebus3000 avatar Sep 17 '19 05:09 jeebus3000