mirror of
https://github.com/penpot/penpot.git
synced 2025-08-02 23:38:30 +02:00
🐛 Fix vertical positioning.
This commit is contained in:
parent
65c9c46a22
commit
1dfc604cf0
4 changed files with 39 additions and 171 deletions
|
@ -156,21 +156,14 @@
|
|||
|
||||
(s/def ::ids (s/coll-of ::us/uuid))
|
||||
(s/def ::attr keyword?)
|
||||
(s/def ::val any?)
|
||||
(s/def ::val any?)
|
||||
(s/def ::frame-id uuid?)
|
||||
(s/def ::loc #{:top :bottom :up :down})
|
||||
|
||||
(defmulti operation-spec-impl :type)
|
||||
|
||||
(defmethod operation-spec-impl :set [_]
|
||||
(s/keys :req-un [::attr ::val]))
|
||||
|
||||
(defmethod operation-spec-impl :abs-order [_]
|
||||
(s/keys :req-un [::id ::index]))
|
||||
|
||||
(defmethod operation-spec-impl :rel-order [_]
|
||||
(s/keys :req-un [::id ::loc]))
|
||||
|
||||
(s/def ::operation (s/multi-spec operation-spec-impl :type))
|
||||
(s/def ::operations (s/coll-of ::operation))
|
||||
|
||||
|
@ -465,7 +458,6 @@
|
|||
(reduce remove-from-old-parent $ shapes)
|
||||
(reduce update-frame-ids $ (get-in $ [:objects parent-id :shapes]))))))
|
||||
|
||||
|
||||
(defmethod process-operation :set
|
||||
[shape op]
|
||||
(let [attr (:attr op)
|
||||
|
@ -474,32 +466,6 @@
|
|||
(dissoc shape attr)
|
||||
(assoc shape attr val))))
|
||||
|
||||
(defmethod process-operation :abs-order
|
||||
[obj {:keys [id index]}]
|
||||
(assert (vector? (:shapes obj)) ":shapes should be a vector")
|
||||
(update obj :shapes (fn [items]
|
||||
(let [[b a] (->> (remove #(= % id) items)
|
||||
(split-at index))]
|
||||
(vec (concat b [id] a))))))
|
||||
|
||||
|
||||
(defmethod process-operation :rel-order
|
||||
[obj {:keys [id loc] :as change}]
|
||||
(assert (vector? (:shapes obj)) ":shapes should be a vector")
|
||||
(let [shapes (:shapes obj)
|
||||
cindex (d/index-of shapes id)
|
||||
nindex (case loc
|
||||
:top (- (count shapes) 1)
|
||||
:down (max 0 (- cindex 1))
|
||||
:up (min (- (count shapes) 1) (inc cindex))
|
||||
:bottom 0)]
|
||||
(update obj :shapes
|
||||
(fn [shapes]
|
||||
(let [[fst snd] (->> (remove #(= % id) shapes)
|
||||
(split-at nindex))]
|
||||
(d/concat [] fst [id] snd))))))
|
||||
|
||||
|
||||
(defmethod process-operation :default
|
||||
[shape op]
|
||||
(ex/raise :type :operation-not-implemented
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue