infinite-canvas-tutorial icon indicating copy to clipboard operation
infinite-canvas-tutorial copied to clipboard

Implement flex layout

Open xiaoiver opened this issue 11 months ago • 0 comments

If we want to place a paragraph in a container, keeping it centered horizontally and vertically:

const container = new Rect({
  x: 0,
  y: 0,
  width: 100,
  height: 100,
  display: 'flex',
  alignItems: 'center',
  justifyContent: 'center'
});
const paragraph = new Text({
  content: 'Line 1 \n Line 2 \n Line 3',
});

container.appendChild(paragraph);

So we need the help of layout engine such as Yoga.

Other flex layout implementations:

xiaoiver avatar Dec 27 '24 02:12 xiaoiver