mirror of
https://github.com/penpot/penpot.git
synced 2025-02-13 18:48:37 -05:00
✨ Fixes problem with frame movement
This commit is contained in:
parent
d737069ef9
commit
57b2141166
3 changed files with 22 additions and 23 deletions
|
@ -1505,7 +1505,7 @@
|
|||
(let [page-id (::page-id state)
|
||||
objects (get-in state [:workspace-data page-id :objects])
|
||||
|
||||
;; Updates the displacement data for a single shape
|
||||
;; Updates the resize data for a single shape
|
||||
materialize-shape
|
||||
(fn [state id mtx]
|
||||
(update-in
|
||||
|
@ -1525,9 +1525,11 @@
|
|||
(fn [state id]
|
||||
(let [shape (get objects id)
|
||||
mtx (:resize-modifier shape (gmt/matrix))]
|
||||
(-> state
|
||||
(materialize-shape id mtx)
|
||||
(materialize-children id mtx))))]
|
||||
(if (= (:type shape) :frame)
|
||||
(materialize-shape state id mtx)
|
||||
(-> state
|
||||
(materialize-shape id mtx)
|
||||
(materialize-children id mtx)))))]
|
||||
(reduce update-shapes state ids)))
|
||||
|
||||
ptk/WatchEvent
|
||||
|
@ -1628,7 +1630,7 @@
|
|||
(dissoc :displacement-modifier)
|
||||
(geom/transform xfmt))
|
||||
|
||||
shapes (->> (:shapes frame)
|
||||
shapes (->> (helpers/get-children id objects)
|
||||
(map #(get objects %))
|
||||
(map #(geom/transform % xfmt))
|
||||
(d/index-by :id))
|
||||
|
|
|
@ -588,12 +588,13 @@
|
|||
(> ry2 sy1))))
|
||||
|
||||
(defn transform-shape
|
||||
[frame shape]
|
||||
(let [ds-modifier (:displacement-modifier shape)
|
||||
rz-modifier (:resize-modifier shape)
|
||||
ds-modifier' (:displacement-modifier frame)]
|
||||
(cond-> shape
|
||||
(gmt/matrix? ds-modifier') (transform ds-modifier')
|
||||
(gmt/matrix? rz-modifier) (transform rz-modifier)
|
||||
frame (move (gpt/point (- (:x frame)) (- (:y frame))))
|
||||
(gmt/matrix? ds-modifier) (transform ds-modifier))))
|
||||
([shape] (transform-shape nil shape))
|
||||
([frame shape]
|
||||
(let [ds-modifier (:displacement-modifier shape)
|
||||
rz-modifier (:resize-modifier shape)
|
||||
frame-ds-modifier (:displacement-modifier frame)]
|
||||
(cond-> shape
|
||||
(gmt/matrix? rz-modifier) (transform rz-modifier)
|
||||
frame (move (gpt/point (- (:x frame)) (- (:y frame))))
|
||||
(gmt/matrix? frame-ds-modifier) (transform frame-ds-modifier)
|
||||
(gmt/matrix? ds-modifier) (transform ds-modifier)))))
|
||||
|
|
|
@ -102,17 +102,11 @@
|
|||
[:& frame-shape {:shape shape
|
||||
:childs childs}]])))))
|
||||
|
||||
(defn frame-shape
|
||||
(defn frame-shape
|
||||
[shape-wrapper]
|
||||
(mf/fnc frame-shape
|
||||
[{:keys [shape childs] :as props}]
|
||||
(let [rotation (:rotation shape)
|
||||
ds-modifier (:displacement-modifier shape)
|
||||
rz-modifier (:resize-modifier shape)
|
||||
shape (cond-> shape
|
||||
(gmt/matrix? rz-modifier) (geom/transform rz-modifier)
|
||||
(gmt/matrix? ds-modifier) (geom/transform ds-modifier))
|
||||
|
||||
(let [shape (geom/transform-shape shape)
|
||||
{:keys [id x y width height]} shape
|
||||
|
||||
props (-> (attrs/extract-style-attrs shape)
|
||||
|
@ -126,5 +120,7 @@
|
|||
[:svg {:x x :y y :width width :height height}
|
||||
[:> "rect" props]
|
||||
(for [item childs]
|
||||
[:& shape-wrapper {:frame shape :shape item :key (:id item)}])])))
|
||||
[:& shape-wrapper {:frame shape
|
||||
:shape item
|
||||
:key (:id item)}])])))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue