Aspect ratio does not respect min/max dimensions #677

Open
opened 2017-11-30 22:55:22 -08:00 by michaelmerrild · 3 comments
michaelmerrild commented 2017-11-30 22:55:22 -08:00 (Migrated from github.com)

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.

# Report - [x] I have searched [existing issues](https://github.com/facebook/yoga/issues) and this is not a duplicate # 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. ```javascript 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 2018-11-28 08:24:00 -08:00 (Migrated from github.com)

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.

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 2020-12-08 05:36:20 -08:00 (Migrated from github.com)

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

Is facebook maintaining issues on github? Issue is 3 years old without any response
u873838 commented 2024-11-05 13:41:49 -08:00 (Migrated from github.com)

Just ran into this issue today.

Just ran into this issue today.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DaddyFrosty/yoga#677
No description provided.