0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-12 18:18:24 -05:00

🐛 Fix problem when duplicating/moving tracks

This commit is contained in:
alonso.torres 2024-01-03 12:20:42 +01:00
parent 5159438e5d
commit 3ae1a97bc9

View file

@ -622,7 +622,7 @@
(defn remove-cell-areas
"Remove the areas in the given `index` before and after the index"
[parent prop index]
(let [prop-span (if (= prop :column) :row-span :column-span)
(let [prop-span (if (= prop :column) :column-span :row-span)
cells (if (= prop :column) (cells-by-column parent index) (cells-by-row parent index))]
(->> cells
(filter #(> (get % prop-span) 1))
@ -654,7 +654,7 @@
"Remove the areas in the given `index` but only after the index."
[parent prop index]
(let [prop-span (if (= prop :column) :column-span :row-span)
cells (if (= type :column) (cells-by-column parent index) (cells-by-row parent index))]
cells (if (= prop :column) (cells-by-column parent index) (cells-by-row parent index))]
(->> cells
(filter #(> (get % prop-span) 1))
(reduce
@ -924,7 +924,7 @@
(cond-> parent
move-content?
(-> (remove-cell-areas prop (dec from-track))
(remove-cell-areas prop (dec to-track))))
(remove-cell-areas-after prop (- to-track 2))))
parent
(reorder-grid-tracks parent tracks-props from-index to-index)]
@ -1376,24 +1376,26 @@
(cells-by-row parent index true))
([parent index check-span?]
(->> (:layout-grid-cells parent)
(filter (fn [[_ {:keys [row row-span]}]]
(if check-span?
(and (>= (inc index) row)
(< (inc index) (+ row row-span)))
(= (inc index) row))))
(map second))))
(vals)
(filter
(fn [{:keys [row row-span]}]
(if check-span?
(and (>= (inc index) row)
(< (inc index) (+ row row-span)))
(= (inc index) row)))))))
(defn cells-by-column
([parent index]
(cells-by-column parent index true))
([parent index check-span?]
(->> (:layout-grid-cells parent)
(filter (fn [[_ {:keys [column column-span]}]]
(if check-span?
(and (>= (inc index) column)
(< (inc index) (+ column column-span)))
(= (inc index) column))))
(map second))))
(vals)
(filter
(fn [{:keys [column column-span] :as cell}]
(if check-span?
(and (>= (inc index) column)
(< (inc index) (+ column column-span)))
(= (inc index) column)))))))
(defn shapes-by-row
([parent index]