diff --git a/CHANGES.md b/CHANGES.md index a1033b537..2b9527806 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -73,6 +73,7 @@ - Fix last update project timer update after creating new file [Taiga #5096](https://tree.taiga.io/project/penpot/issue/5096) - Fix dashboard scrolling using 'Page Up' and 'Page Down' [Taiga #5081](https://tree.taiga.io/project/penpot/issue/5081) - Fix view mode header buttons overlapping in small resolutions [Taiga #5058](https://tree.taiga.io/project/penpot/issue/5058) +- Fix precision for wrap in flex [Taiga #5072](https://tree.taiga.io/project/penpot/issue/5072) ### :heart: Community contributions by (Thank you!) - To @ondrejkonec: for contributing to the code with: diff --git a/common/src/app/common/geom/shapes/flex_layout/lines.cljc b/common/src/app/common/geom/shapes/flex_layout/lines.cljc index b5d89c378..3692e9fb4 100644 --- a/common/src/app/common/geom/shapes/flex_layout/lines.cljc +++ b/common/src/app/common/geom/shapes/flex_layout/lines.cljc @@ -104,8 +104,10 @@ (if (and (some? line-data) (or (not wrap?) - (and row? (<= next-line-min-width layout-width)) - (and col? (<= next-line-min-height layout-height)))) + (and row? (or (< next-line-min-width layout-width) + (mth/close? next-line-min-width layout-width 0.5))) + (and col? (or (< next-line-min-height layout-height) + (mth/close? next-line-min-height layout-height 0.5))))) (recur {:line-min-width (if row? (+ line-min-width next-min-width) (max line-min-width next-min-width)) :line-max-width (if row? (+ line-max-width next-max-width) (max line-max-width next-max-width)) diff --git a/common/src/app/common/math.cljc b/common/src/app/common/math.cljc index d3f724ee9..0adc340be 100644 --- a/common/src/app/common/math.cljc +++ b/common/src/app/common/math.cljc @@ -185,8 +185,10 @@ (defn close? "Equality for float numbers. Check if the difference is within a range" - [num1 num2] - (<= (abs (- num1 num2)) float-equal-precision)) + ([num1 num2] + (close? num1 num2 float-equal-precision)) + ([num1 num2 precision] + (<= (abs (- num1 num2)) precision))) (defn lerp "Calculates a the linear interpolation between two values and a given percent"