mirror of
https://github.com/penpot/penpot.git
synced 2025-06-27 18:06:59 +02: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)
|
(let [page-id (::page-id state)
|
||||||
objects (get-in state [:workspace-data page-id :objects])
|
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
|
materialize-shape
|
||||||
(fn [state id mtx]
|
(fn [state id mtx]
|
||||||
(update-in
|
(update-in
|
||||||
|
@ -1525,9 +1525,11 @@
|
||||||
(fn [state id]
|
(fn [state id]
|
||||||
(let [shape (get objects id)
|
(let [shape (get objects id)
|
||||||
mtx (:resize-modifier shape (gmt/matrix))]
|
mtx (:resize-modifier shape (gmt/matrix))]
|
||||||
|
(if (= (:type shape) :frame)
|
||||||
|
(materialize-shape state id mtx)
|
||||||
(-> state
|
(-> state
|
||||||
(materialize-shape id mtx)
|
(materialize-shape id mtx)
|
||||||
(materialize-children id mtx))))]
|
(materialize-children id mtx)))))]
|
||||||
(reduce update-shapes state ids)))
|
(reduce update-shapes state ids)))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
|
@ -1628,7 +1630,7 @@
|
||||||
(dissoc :displacement-modifier)
|
(dissoc :displacement-modifier)
|
||||||
(geom/transform xfmt))
|
(geom/transform xfmt))
|
||||||
|
|
||||||
shapes (->> (:shapes frame)
|
shapes (->> (helpers/get-children id objects)
|
||||||
(map #(get objects %))
|
(map #(get objects %))
|
||||||
(map #(geom/transform % xfmt))
|
(map #(geom/transform % xfmt))
|
||||||
(d/index-by :id))
|
(d/index-by :id))
|
||||||
|
|
|
@ -588,12 +588,13 @@
|
||||||
(> ry2 sy1))))
|
(> ry2 sy1))))
|
||||||
|
|
||||||
(defn transform-shape
|
(defn transform-shape
|
||||||
[frame shape]
|
([shape] (transform-shape nil shape))
|
||||||
|
([frame shape]
|
||||||
(let [ds-modifier (:displacement-modifier shape)
|
(let [ds-modifier (:displacement-modifier shape)
|
||||||
rz-modifier (:resize-modifier shape)
|
rz-modifier (:resize-modifier shape)
|
||||||
ds-modifier' (:displacement-modifier frame)]
|
frame-ds-modifier (:displacement-modifier frame)]
|
||||||
(cond-> shape
|
(cond-> shape
|
||||||
(gmt/matrix? ds-modifier') (transform ds-modifier')
|
|
||||||
(gmt/matrix? rz-modifier) (transform rz-modifier)
|
(gmt/matrix? rz-modifier) (transform rz-modifier)
|
||||||
frame (move (gpt/point (- (:x frame)) (- (:y frame))))
|
frame (move (gpt/point (- (:x frame)) (- (:y frame))))
|
||||||
(gmt/matrix? ds-modifier) (transform ds-modifier))))
|
(gmt/matrix? frame-ds-modifier) (transform frame-ds-modifier)
|
||||||
|
(gmt/matrix? ds-modifier) (transform ds-modifier)))))
|
||||||
|
|
|
@ -106,13 +106,7 @@
|
||||||
[shape-wrapper]
|
[shape-wrapper]
|
||||||
(mf/fnc frame-shape
|
(mf/fnc frame-shape
|
||||||
[{:keys [shape childs] :as props}]
|
[{:keys [shape childs] :as props}]
|
||||||
(let [rotation (:rotation shape)
|
(let [shape (geom/transform-shape 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))
|
|
||||||
|
|
||||||
{:keys [id x y width height]} shape
|
{:keys [id x y width height]} shape
|
||||||
|
|
||||||
props (-> (attrs/extract-style-attrs shape)
|
props (-> (attrs/extract-style-attrs shape)
|
||||||
|
@ -126,5 +120,7 @@
|
||||||
[:svg {:x x :y y :width width :height height}
|
[:svg {:x x :y y :width width :height height}
|
||||||
[:> "rect" props]
|
[:> "rect" props]
|
||||||
(for [item childs]
|
(for [item childs]
|
||||||
[:& shape-wrapper {:frame shape :shape item :key (:id item)}])])))
|
[:& shape-wrapper {:frame shape
|
||||||
|
:shape item
|
||||||
|
:key (:id item)}])])))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue