Open zamotany opened 5 years ago
@zamotany You are totally right. My bad. Yeah if you would like to make a PR (and add a test for it so I don't mess up again ^^) that would be awesome. Let me know, otherwise I'll write a fix for it when I have some downtime.
btw react-slate looks awesome! Congrats on a successful project 💯
Also sorry for the delay in getting back to you on this.
@emilsjolander Sure, I'll make a PR
Any chance we can get this fix merged ? I'm looking into replacing yoga-layout in my own project with stretch-layout but the broken percentage dimensions is a showstopper.
First of all, this is an awesome project and I really appreciate everyone putting their effort into it.
While working on react-slate (a React renderer for terminal in Node JS), which is based on Stretch, I noticed that, when setting
width
/height
, basically anyDimension
property as a percentage, it is converted to plainPoints
:setting
width
to100%
will result inPoints(100)
being used in layout calculations.I've done some digging and found one line of code, which might be causing that in
get_dimension
function inbindings/js
: https://github.com/vislyhq/stretch/blob/a7e2c07bc343a1f16e1d651ea9f0c17fb0fbd098/bindings/js/src/lib.rs#L608-L613Shouldn't this
if let
returnreturn stretch::style::Dimension::Percent(number / 100);
?I'm happy to do a PR to fix that, but wanted a feedback before doing so.