From 7c215dc11bc3aada2fe82059864cb6cb2e9fd2c7 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 2 Feb 2023 13:24:28 +0100 Subject: [PATCH] :bug: Align-items center/end weren't respected when layout was outside bounds --- .../common/geom/shapes/flex_layout/positions.cljc | 10 +++++++--- common/src/app/common/types/shape/layout.cljc | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/common/src/app/common/geom/shapes/flex_layout/positions.cljc b/common/src/app/common/geom/shapes/flex_layout/positions.cljc index 2e2e44bfd..77ce23d0b 100644 --- a/common/src/app/common/geom/shapes/flex_layout/positions.cljc +++ b/common/src/app/common/geom/shapes/flex_layout/positions.cljc @@ -20,9 +20,13 @@ hv (partial gpo/start-hv layout-bounds) vv (partial gpo/start-vv layout-bounds) - end? (ctl/content-end? parent) - center? (ctl/content-center? parent) - around? (ctl/content-around? parent) + wrap? (ctl/wrap? parent) + + end? (or (and wrap? (ctl/content-end? parent)) + (and (not wrap?) (ctl/align-items-end? parent))) + center? (or (and wrap? (ctl/content-center? parent)) + (and (not wrap?) (ctl/align-items-center? parent))) + around? (and wrap? (ctl/content-around? parent)) ;; Adjust the totals so it takes into account the gaps [layout-gap-row layout-gap-col] (ctl/gaps parent) diff --git a/common/src/app/common/types/shape/layout.cljc b/common/src/app/common/types/shape/layout.cljc index 8d619cc6c..9be46671f 100644 --- a/common/src/app/common/types/shape/layout.cljc +++ b/common/src/app/common/types/shape/layout.cljc @@ -275,6 +275,21 @@ (or (= :stretch layout-align-content) (nil? layout-align-content))) +(defn align-items-center? + [{:keys [layout-align-items]}] + (= layout-align-items :center)) + +(defn align-items-start? + [{:keys [layout-align-items]}] + (= layout-align-items :start)) + +(defn align-items-end? + [{:keys [layout-align-items]}] + (= layout-align-items :end)) + +(defn align-items-stretch? + [{:keys [layout-align-items]}] + (= layout-align-items :stretch)) (defn reverse? [{:keys [layout-flex-dir]}]