Comments (3)
@NickGerleman spent some time digging into this. The issue is how the combination of aspectRatio + alignItems stretch is being treated in browser vs yoga. Aspect ratio is initially used to calculate the dimension in both browser and yoga but if the align items is set to stretch then the child will grow to the cross axis flex line dimension in browser whereas in yoga it'll always respect the aspect ratio. In the below line, if we don't consider aspect ratio when align items is stretch, we get the same result in browser and yoga.
yoga/yoga/algorithm/CalculateLayout.cpp
Line 1886 in bac658b
Try below snippet without gap. It also varies between browser and yoga. I can also see some more inconsistencies in margin and aspect ratio behavior. There is some issue in how aspect ratio is treated compared to browser. I'll dig with the specs and update when I have more findings.
<View style={{ flex: 1, overflow: "scroll" }}>
<View style={{ flexDirection: "row", backgroundColor: "red" }}>
<View
style={{
flex: 2,
aspectRatio: 1,
backgroundColor: "blue",
}}
/>
<View style={{ width: 5 }} />
<View style={{ flex: 1 }}>
<View
style={{
flex: 1,
aspectRatio: 1,
backgroundColor: "blue",
}}
/>
<View style={{ height: 5 }} />
<View style={{ flex: 1, aspectRatio: 1, backgroundColor: "blue" }} />
</View>
</View>
</View>;
from yoga.
@intergalacticspacehighway great work, as always 🙂.
@nicoburns helpfully created #1295 a while back with a set of fixtures used by Taffy for aspect ratio, showing differences between Yoga and browser behavior. The story here being that aspectRatio in Yoga predates the aspectRatio property in CSS.
I will retitle this issue for clarity, since it seems like we think the root issue here is around Yogas handling of aspect ratio for flexible items (at least for stretched cross axis).
from yoga.
Related, even with the workaround I've posted (flexGrow
), if you apply borderRadius to images, you'll notice they slightly go outside the container (the border radius gets cut off at the right bottom). I've ended up refactoring my workaround to use margins instead for this reason.
from yoga.
Related Issues (20)
- Flex shorthand in UseWebDefaults should set basis to 0 instead of auto HOT 3
- React Native iOS build failed HOT 1
- top position is wrong when previous item's height is 0.5, on 3x scale screen HOT 1
- API proposal to get the computed measure size of a node HOT 9
- Proposal: Integrate with google/oss-fuzz for continuous fuzz testing? HOT 9
- Can a Yoga Node have multiple owners? HOT 3
- [JS] Reduce WASM call overhead HOT 6
- Add App Privacy Manifest? HOT 1
- `flexBasis` doesn't recalculate when rotating the screen HOT 1
- __dirname is not defined in ES module scope HOT 3
- RuntimeError with WebAssembly in @react-pdf/yoga on Node.js Server HOT 3
- Why can't we round node width/height directly in roundLayoutResultsToPixelGrid()? HOT 3
- The typescript definitions link in the standalone documentation is incorrect HOT 2
- Build of v3 with GCC11 fails HOT 3
- Add a CMake option to not build the tests HOT 2
- Add Conan badge HOT 1
- Percentage padding not updated when the parent size changes HOT 4
- Discrepancy between playground and C++ HOT 1
- Where is the operation interface?
- Where is the operation interface? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yoga.