mirror of
https://github.com/penpot/penpot.git
synced 2025-04-04 19:11:20 -05:00
🐛 Fix problem with grid layout crashing (#5831)
This commit is contained in:
parent
4f38d258b5
commit
fb24a37e83
3 changed files with 60 additions and 55 deletions
|
@ -62,6 +62,7 @@ is a number of cores)
|
|||
- Added upload svg with images method [#5489](https://github.com/penpot/penpot/issues/5489)
|
||||
- Fix problem with root frame parent reference [Taiga #9437](https://tree.taiga.io/project/penpot/issue/9437)
|
||||
- Fix change flex direction using plugins API [Taiga #9407](https://tree.taiga.io/project/penpot/issue/9407)
|
||||
- Fix problem with grid layout crashing [Taiga #10127](https://tree.taiga.io/project/penpot/issue/10127)
|
||||
|
||||
## 2.4.3
|
||||
|
||||
|
|
|
@ -212,8 +212,10 @@
|
|||
(if (= type :column)
|
||||
[:column :column-span]
|
||||
[:row :row-span])
|
||||
from-idx (dec (get cell prop))
|
||||
to-idx (+ (dec (get cell prop)) (get cell prop-span))
|
||||
from-idx (-> (dec (get cell prop))
|
||||
(mth/clamp 0 (dec (count track-list))))
|
||||
to-idx (-> (+ (dec (get cell prop)) (get cell prop-span))
|
||||
(mth/clamp 0 (dec (count track-list))))
|
||||
tracks (subvec track-list from-idx to-idx)]
|
||||
(some? (->> tracks (d/seek #(= :flex (:type %)))))))
|
||||
|
||||
|
@ -291,8 +293,10 @@
|
|||
(fn [allocated cell]
|
||||
(let [shape-id (first (:shapes cell))
|
||||
|
||||
from-idx (dec (get cell prop))
|
||||
to-idx (+ (dec (get cell prop)) (get cell prop-span))
|
||||
from-idx (-> (dec (get cell prop))
|
||||
(mth/clamp 0 (dec (count track-list))))
|
||||
to-idx (-> (+ (dec (get cell prop)) (get cell prop-span))
|
||||
(mth/clamp 0 (dec (count track-list))))
|
||||
|
||||
indexed-tracks (subvec (d/enumerate track-list) from-idx to-idx)
|
||||
to-allocate (size-to-allocate type parent (get children-map shape-id) cell bounds objects)
|
||||
|
@ -597,11 +601,10 @@
|
|||
row (nth row-tracks (dec (:row grid-cell)) nil)
|
||||
|
||||
column-start-p (:start-p column)
|
||||
row-start-p (:start-p row)
|
||||
|
||||
start-p (gpt/add origin
|
||||
(gpt/add
|
||||
(gpt/to-vec origin column-start-p)
|
||||
(gpt/to-vec origin row-start-p)))]
|
||||
|
||||
(assoc grid-cell :start-p start-p)))))
|
||||
row-start-p (:start-p row)]
|
||||
(when (and (some? column-start-p) (some? row-start-p))
|
||||
(let [start-p (gpt/add origin
|
||||
(gpt/add
|
||||
(gpt/to-vec origin column-start-p)
|
||||
(gpt/to-vec origin row-start-p)))]
|
||||
(assoc grid-cell :start-p start-p)))))))
|
||||
|
|
|
@ -114,61 +114,62 @@
|
|||
|
||||
(defn child-position-delta
|
||||
[parent child child-bounds child-width child-height layout-data cell-data]
|
||||
(let [cell-bounds (cell-bounds layout-data cell-data)
|
||||
child-origin (gpo/origin child-bounds)
|
||||
(if-let [cell-bounds (cell-bounds layout-data cell-data)]
|
||||
(let [child-origin (gpo/origin child-bounds)
|
||||
|
||||
align (:layout-align-items parent)
|
||||
justify (:layout-justify-items parent)
|
||||
align-self (:align-self cell-data)
|
||||
justify-self (:justify-self cell-data)
|
||||
align (:layout-align-items parent)
|
||||
justify (:layout-justify-items parent)
|
||||
align-self (:align-self cell-data)
|
||||
justify-self (:justify-self cell-data)
|
||||
|
||||
align-self (when (and align-self (not= align-self :auto)) align-self)
|
||||
justify-self (when (and justify-self (not= justify-self :auto)) justify-self)
|
||||
align-self (when (and align-self (not= align-self :auto)) align-self)
|
||||
justify-self (when (and justify-self (not= justify-self :auto)) justify-self)
|
||||
|
||||
align (or align-self align)
|
||||
justify (or justify-self justify)
|
||||
align (or align-self align)
|
||||
justify (or justify-self justify)
|
||||
|
||||
origin-h (gpo/project-point cell-bounds :h child-origin)
|
||||
origin-v (gpo/project-point cell-bounds :v child-origin)
|
||||
hv (partial gpo/start-hv cell-bounds)
|
||||
vv (partial gpo/start-vv cell-bounds)
|
||||
origin-h (gpo/project-point cell-bounds :h child-origin)
|
||||
origin-v (gpo/project-point cell-bounds :v child-origin)
|
||||
hv (partial gpo/start-hv cell-bounds)
|
||||
vv (partial gpo/start-vv cell-bounds)
|
||||
|
||||
[top-m right-m bottom-m left-m] (ctl/child-margins child)
|
||||
[top-m right-m bottom-m left-m] (ctl/child-margins child)
|
||||
|
||||
;; Adjust alignment/justify
|
||||
[from-h to-h]
|
||||
(case justify
|
||||
:end
|
||||
[(gpt/add origin-h (hv child-width))
|
||||
(gpt/subtract (nth cell-bounds 1) (hv right-m))]
|
||||
;; Adjust alignment/justify
|
||||
[from-h to-h]
|
||||
(case justify
|
||||
:end
|
||||
[(gpt/add origin-h (hv child-width))
|
||||
(gpt/subtract (nth cell-bounds 1) (hv right-m))]
|
||||
|
||||
:center
|
||||
[(gpt/add origin-h (hv (/ child-width 2)))
|
||||
(-> (gpo/project-point cell-bounds :h (gpo/center cell-bounds))
|
||||
(gpt/add (hv (/ left-m 2)))
|
||||
(gpt/subtract (hv (/ right-m 2))))]
|
||||
:center
|
||||
[(gpt/add origin-h (hv (/ child-width 2)))
|
||||
(-> (gpo/project-point cell-bounds :h (gpo/center cell-bounds))
|
||||
(gpt/add (hv (/ left-m 2)))
|
||||
(gpt/subtract (hv (/ right-m 2))))]
|
||||
|
||||
[origin-h
|
||||
(gpt/add (first cell-bounds) (hv left-m))])
|
||||
[origin-h
|
||||
(gpt/add (first cell-bounds) (hv left-m))])
|
||||
|
||||
[from-v to-v]
|
||||
(case align
|
||||
:end
|
||||
[(gpt/add origin-v (vv child-height))
|
||||
(gpt/subtract (nth cell-bounds 3) (vv bottom-m))]
|
||||
[from-v to-v]
|
||||
(case align
|
||||
:end
|
||||
[(gpt/add origin-v (vv child-height))
|
||||
(gpt/subtract (nth cell-bounds 3) (vv bottom-m))]
|
||||
|
||||
:center
|
||||
[(gpt/add origin-v (vv (/ child-height 2)))
|
||||
(-> (gpo/project-point cell-bounds :v (gpo/center cell-bounds))
|
||||
(gpt/add (vv top-m))
|
||||
(gpt/subtract (vv bottom-m)))]
|
||||
:center
|
||||
[(gpt/add origin-v (vv (/ child-height 2)))
|
||||
(-> (gpo/project-point cell-bounds :v (gpo/center cell-bounds))
|
||||
(gpt/add (vv top-m))
|
||||
(gpt/subtract (vv bottom-m)))]
|
||||
|
||||
[origin-v
|
||||
(gpt/add (first cell-bounds) (vv top-m))])]
|
||||
[origin-v
|
||||
(gpt/add (first cell-bounds) (vv top-m))])]
|
||||
|
||||
(-> (gpt/point)
|
||||
(gpt/add (gpt/to-vec from-h to-h))
|
||||
(gpt/add (gpt/to-vec from-v to-v)))))
|
||||
(-> (gpt/point)
|
||||
(gpt/add (gpt/to-vec from-h to-h))
|
||||
(gpt/add (gpt/to-vec from-v to-v))))
|
||||
(gpt/point 0 0)))
|
||||
|
||||
(defn child-modifiers
|
||||
[parent parent-bounds child child-bounds layout-data cell-data]
|
||||
|
|
Loading…
Add table
Reference in a new issue