facebook / yoga

Yoga is an embeddable layout engine targeting web standards.
https://yogalayout.dev/
MIT License
17.32k stars 1.44k forks source link

Aspect ratio does not respect min/max dimensions #677

Open michaelmerrild opened 6 years ago

michaelmerrild commented 6 years ago

Report

Issues and Steps to Reproduce

Aspect ratio does not respect min/max dimensions.

In the example below, the computed height is 200, but should be 50 because max-width is set.

const assert = require('assert');
const yoga = require('yoga-layout');

let rootNode = yoga.Node.create();
let childNode = yoga.Node.create();

childNode.setWidth(400);
childNode.setMaxWidth(100);
childNode.setAspectRatio(2);

rootNode.insertChild(childNode, 0);
rootNode.calculateLayout(1080, 768);

assert.strictEqual(childNode.getComputedWidth(), 100);
assert.strictEqual(childNode.getComputedHeight(), 50);

rootNode.freeRecursive();

Expected Behavior

The documentation states that

AspectRatio respects the Min and Max dimensions of an item.

Actual Behavior

The height is calculated based on the explicit width.

nick-thompson commented 5 years ago

Hey @michaelmerrild I'm currently seeing the same thing on the latest master. Did this get anywhere?

Edit: probably should mention I'm using the C/C++ library directly.

Edit(2): Just rolled back from master to 1.10.0, this issue is still present.

Strate commented 3 years ago

Is facebook maintaining issues on github? Issue is 3 years old without any response

u873838 commented 2 weeks ago

Just ran into this issue today.