Swiftpack.co - Package - facebook/yoga

Yoga CocoaPods npm bintray NuGet

Building

Yoga builds with buck. Make sure you install buck before contributing to Yoga. Yoga's main implementation is in C++, with bindings to supported languages and frameworks. When making changes to Yoga please ensure the changes are also propagated to these bindings when applicable.

Testing

For testing we rely on gtest as a submodule. After cloning Yoga run git submodule init followed by git submodule update.

For any changes you make you should ensure that all the tests are passing. In case you make any fixes or additions to the library please also add tests for that change to ensure we don't break anything in the future. Tests are located in the tests directory. Run the tests by executing buck test //:yoga.

Instead of manually writing a test which ensures parity with web implementations of Flexbox you can run gentest/gentest.rb to generate a test for you. You can write html which you want to verify in Yoga, in gentest/fixtures folder, such as the following.

<div id="my_test" style="width: 100px; height: 100px; align-items: center;">
  <div style="width: 50px; height: 50px;"></div>
</div>

Run gentest/gentest.rb to generate test code and re-run buck test //:yoga to validate the behavior. One test case will be generated for every root div in the input html.

You may need to install the latest watir-webdriver gem (gem install watir-webdriver) and ChromeDriver to run gentest/gentest.rb Ruby script.

.NET

.NET testing is not integrated in buck yet, you might need to set up .NET testing environment. We have a script which to launch C# test on macOS, csharp/tests/Facebook.Yoga/test_macos.sh.

Benchmarks

Benchmarks are located in benchmark/YGBenchmark.c and can be run with buck run //benchmark:benchmark. If you think your change has affected performance please run this before and after your change to validate that nothing has regressed. Benchmarks are run on every commit in CI.

JavaScript

Installing through NPM

npm install yoga-layout

By default this will install the library and try to build for all platforms (node, browser asm, and standalone webpack). You may receive errors if you do not have the required platform development tools already installed. To preset the platform you'd like to build for you can set a .npmrc property first.

npm config set yoga-layout:platform standalone

This will now only run the standalone webpack build upon install.

Build Platforms

| name | description | |----------------|-------------------------------------------------| | all (default) | Builds all of these platforms. | | browser | Builds asm js browser version. | | node | Builds node js version. | | standalone | Runs webpack. | | none | Does nothing. You can use the prepackaged libs. |

Github

link
Stars: 13700

Dependencies

Used By

Total: 1

Releases

v1.18.0 - 2019-11-08 13:54:53

v1.17.0 - 2019-11-07 21:30:10

v1.16.0 - 2019-09-16 15:24:54

v1.14.0 - 2019-04-08 18:11:44

New stable with some bug fixes around align-content

v1.12.0-pre.3 - 2019-03-22 19:14:06

Fix YogaKit sample project

v1.12.0-pre.2 - 2019-03-22 17:36:36

Fixed YogaKit workspace

v1.13.0 - 2019-03-04 15:54:48

v1.12.0-pre.1 - 2019-03-04 10:04:52

Pre-release with exposed YGSetUsedCachedEntries. This will go away again!

v1.11.0 - 2019-02-12 12:52:59

v1.10.0 - 2018-10-05 20:37:26

1.9.0 - 2018-07-12 16:06:38

Release for sonar

- 2018-03-06 11:25:23

v1.6.0 - 2017-07-13 18:59:45

This release contains a bunch of big fixes:

  • Rounding fixes https://github.com/facebook/yoga/commit/24e2fc95dd996a6de2fcfb1e3aaa8ccdacdc17f2 https://github.com/facebook/yoga/commit/5d75c7c4c8095a033ba77045aba197dc122de7cf https://github.com/facebook/yoga/commit/b378a685a434926cc22a5477a7e764023b066478
  • Flex fixes https://github.com/facebook/yoga/commit/ca2c607f9004303f47870200e8018a634de5b594 https://github.com/facebook/yoga/commit/f2612192c531e0c6c2e9e4089c3c257ba5c0ed8f https://github.com/facebook/yoga/commit/85c2e406e4f75c301313b31f1a67169d7470ff93
  • Absolute layout fixes https://github.com/facebook/yoga/commit/56b10fc35bc3c861030358b263d316371e8ac65e https://github.com/facebook/yoga/commit/629e401debe1e50fd13c25a39e14fb7111fa8c13
  • Overflow fixes https://github.com/facebook/yoga/commit/488a7c1fe0bfea76b645fd1ea4cbd9ccb0578acb https://github.com/facebook/yoga/commit/7640cd667f8c6108c686e11eacc054b0be6d301c
  • Measure fixes https://github.com/facebook/yoga/commit/cd1dbc3f0f668b2835e5db62e16ae33f4add1fc3 https://github.com/facebook/yoga/commit/b2b0c7ee37d48ed3438552dc9cf528f64088bbdb

1.5.0 - 2017-05-10 15:13:42

Big thanks to everyone who contributed to this release.

Bug fixes

  • Measure functions now get called even if no space is left over. This is done for web compatibility. https://github.com/facebook/yoga/commit/f6b17183c5847469c6b13f5af5a498888c6ce4f4
  • Fix bug where items were stretching within parents when they should not. For example when a parent has alignItems:center. To use the legacy behaviour set useLegacyStretchBehaviour on a node's config object. https://github.com/facebook/yoga/commit/203577724ed65e426a39901ceb3e779c7eb5160b
  • Allow flexible root containers in YogaKit. https://github.com/facebook/yoga/commit/849de89a58096c291c26c88b37400fd434ab93b2
  • Fix flex-wrap with max constraint. https://github.com/facebook/yoga/commit/3178e3bf15dac4f52bfc6943af94a061c9e160df

API changes

  • YogaNodeAPI interface no longer exists. https://github.com/facebook/yoga/commit/1b3e9715495142b7500a02adf563243ad0d0b642
  • in C# StyleAspectRatio has been renamed AspectRatio. https://github.com/facebook/yoga/commit/8891ea1a7a066e3121787a888e469aae44fa1b3f
  • YGLogger has moved into YGConfig so it is no longer global. It also passes along a node in cases where it makes sense so you have the ability to show errors based on a node's context. https://github.com/facebook/yoga/commit/91230ae177fdfa6b73cf8aa505e2d91e3bea062f

Features

  • Pixel grid rounding is no longer experimental. We have been using it for a while and this release contains several improvements. Report bugs if you find them. https://github.com/facebook/yoga/commit/aa5b296ac78f7a22e1aeaf4891243c6bb76488e2 https://github.com/facebook/yoga/commit/3db38f2a80cd331bb757eba65baa2d10c9b41f39 https://github.com/facebook/yoga/commit/40e1bf6ce3ff95da4f1df2b64ddcb9caefb9cea9
  • Support for percentage values in YogaKit! https://github.com/facebook/yoga/commit/7b89a1dd4826487bd02a3e63835dfc684790e6a3

1.4.0 - 2017-04-12 09:16:22

Big thanks to @woehrl01 for all the fixes and performance improvements in this release.

Bug fixes

  • Take margin into account on max dimension https://github.com/facebook/yoga/commit/09f0c2d8ce375fe95322055fcdb2361bbb5c11e1
  • Fix align-content: center, flex-end alignment with margin https://github.com/facebook/yoga/commit/b94466e502d9c08ef6399c4f7732d762b525ad71
  • Invalidate layout when node is removed from tree https://github.com/facebook/yoga/commit/249d010dad6b504cf3181e70b6ecfa57ef26e998
  • Set hasNewLayout on display changes. https://github.com/facebook/yoga/commit/ebdf82f4913cc336ed9971e9612ab51f0e661386
  • Fix position on root node with RTL direction https://github.com/facebook/yoga/commit/e9927377b58a2bcac3615d79062ad6d81854bcdc
  • Fix min constraint incorrectly reducing available space https://github.com/facebook/yoga/commit/25f14a191720c4d97c82e131af7dab7574d81332

Performance improvements

  • Reduce the number of expensive JNI calls. https://github.com/facebook/yoga/commit/5884ab7b76a66b2a5b22a8ebd164f7a9b8f551ed https://github.com/facebook/yoga/commit/5112564f083422194cdb1baf1a97c0308cbc14cb

API changes

  • Move point scale factor to reside on the config instead of being a global flag. https://github.com/facebook/yoga/commit/406c8a21175138e9f63e8081bff2d0de588d52e9

Features

  • Allow YogaLayout on android to be created outside of xml. https://github.com/facebook/yoga/commit/f66f52d1bae62b0ad517a113ec508cbf2e4d6c4f
  • Optimize log print by using html format https://github.com/facebook/yoga/commit/586b57009a50d5eaed45981e8ef699001b9a2ed6

1.3.0 - 2017-03-07 13:37:41

Bug fixes

  • Fix bug with display: none not invalidating children properly https://github.com/facebook/yoga/commit/a706f4c97cbf52d66dcf06288c3fd85e955daa36
  • Handle margin-start and margin-end with 'auto' value https://github.com/facebook/yoga/commit/8668e43f6d09f77827c4db9a53923c0586845a56
  • Fix percentages in flexing parents https://github.com/facebook/yoga/commit/17e3dca9f91bddee0bf3771ecf19a0d1595c330d

Behavior changes

  • Pass parent size instead of root size as parameters to YGNodeCalculateLayout. https://github.com/facebook/yoga/commit/1cd7363beada3c5a6af8808dbaa301cbd1a9f43f
  • Flex getters now return the value which was set on them / the default value instead of a computed value. https://github.com/facebook/yoga/commit/3346f9511a77d88173e6d9a71d9c4cdf4dde0716

Features

  • Add ability to configure Yoga to use web defaults https://github.com/facebook/yoga/commit/62f47190fb2c13d47b13efacfc237f30ab312b51
  • Add a configuration option to nodes for things like experiments and various other things which were previously global configs. https://github.com/facebook/yoga/commit/37c48257ae300ffbf0f2644a058270224b347f34

1.2.0 - 2017-02-23 19:27:40

Bug fixes:

  • https://github.com/facebook/yoga/commit/240c2dd6573367cd94bfa4893316347b75b2fc18
  • https://github.com/facebook/yoga/commit/adf8691093d57b75d19f5fc9c9a404a5d7f0cbc7
  • https://github.com/facebook/yoga/commit/063f65d0651c87a7e3d96b94679dacd8a35eb13e
  • https://github.com/facebook/yoga/commit/ea8b7e0c918cab7e976bd05ef2390c5dec33d410
  • https://github.com/facebook/yoga/commit/6b39165801f588f3194ac9986400bc7991218368
  • https://github.com/facebook/yoga/commit/4f5c7ed6afa72dd14e37b73f40fd88b2223a5d45

Behavior changes:

  • Return Undefined for edges without set values and not their computed value. This allows users to correctly check if a value is set / has changed. https://github.com/facebook/yoga/commit/168ae4099d039d20129f44d4eb63499e00db9073

API changes:

  • https://github.com/facebook/yoga/commit/9d2839f8cafccb7a558c5f376f959a5c1e6a4829 Changes YGPixel to be named YGPoint. This is a small change which should not effect most users of the library. Reason for this change is that we will want to start performing more operations on 'points' which don't map to physical pixels.

Features:

  • Add support for space-between and space-around on align-content https://github.com/facebook/yoga/commit/6a7ad2125d2ecb1daf9c0c748b66be959dc18f06
  • Add support for auto margins https://github.com/facebook/yoga/commit/1146013e9eed00b4e20db00b238d0ad5f7184523
  • Add support for wrap-reverse https://github.com/facebook/yoga/commit/20536923d6b7ec41ebf15295abfec754628f5af3

1.1.0 - 2017-02-07 15:11:30

  • Handle minWidth == maxWidth as width. improves perf by not calling measure function. (https://github.com/facebook/yoga/commit/46817a38c310fadc972b60af01e6fc6e3118f271)
  • Added property display: flex and none (https://github.com/facebook/yoga/commit/e567502750731c05bca81ea594927cfab96529de)
  • Return raw style from style setters (https://github.com/facebook/yoga/commit/93e327f4a5dad99d58f54166019b5ff233e79a79)

1.0.1 - 2017-01-28 01:33:12

Small release to facilitate changes in folder structure needed for cocoapods

1.0.0 - 2017-01-26 00:59:43

This is the first official release since the Yoga rename so calling it 1.0.0 as we start with semantic versioning. Future versions will be released on an as needed basis, mostly to release new code to those consuming yoga via package managers.

If you need a new release to be cut please file a task.

Patched v1.1.0 - 2015-11-12 14:35:45

The npm release was faulty, this is v1.1.0, but fixed!

New C# API - 2015-11-11 07:30:03

  • Performance improvements #122 #123 #137 #138 #141
  • Java constants are now public #126
  • C# API added #129, with C# 6 language features suppressed #135, and bugfix #144 (although this still needs to be added to test, CI and release #142)
  • Bug fixed: Fix width being ignored when has a value of 0 #134
  • ESLint applied to codebase #139
  • Reset added to CSSNode #140
  • Improved CSSNode API #146

NOTE: The npm process for this release failed, please use v1.1.1

First Release - 2015-09-08 06:47:52

This is the first public API and moves the project into using semver proper!

Test release - 2015-08-21 10:06:08

A patch release for the purposes of testing the release process.