mirror of
https://github.com/penpot/penpot.git
synced 2025-05-11 18:06:39 +02:00
🐛 Fix token dimension application for all relatively positioned shapes
This commit is contained in:
parent
44ca01aa27
commit
5f3599eaa7
3 changed files with 10 additions and 34 deletions
|
@ -859,12 +859,6 @@
|
||||||
(rx/of (reorder-selected-layout-child direction))
|
(rx/of (reorder-selected-layout-child direction))
|
||||||
(rx/of (nudge-selected-shapes direction shift?)))))))
|
(rx/of (nudge-selected-shapes direction shift?)))))))
|
||||||
|
|
||||||
(defn- get-delta [position bbox]
|
|
||||||
(let [cpos (gpt/point (:x bbox) (:y bbox))
|
|
||||||
pos (gpt/point (or (:x position) (:x bbox))
|
|
||||||
(or (:y position) (:y bbox)))]
|
|
||||||
(gpt/subtract pos cpos)))
|
|
||||||
|
|
||||||
(defn- get-relative-delta [position bbox parent]
|
(defn- get-relative-delta [position bbox parent]
|
||||||
(let [parent-bbox (-> parent :points grc/points->rect)
|
(let [parent-bbox (-> parent :points grc/points->rect)
|
||||||
relative-cpos (gpt/subtract (gpt/point (:x bbox) (:y bbox))
|
relative-cpos (gpt/subtract (gpt/point (:x bbox) (:y bbox))
|
||||||
|
@ -888,10 +882,8 @@
|
||||||
shape (get objects id)
|
shape (get objects id)
|
||||||
;; FIXME: performance rect
|
;; FIXME: performance rect
|
||||||
bbox (-> shape :points grc/points->rect)
|
bbox (-> shape :points grc/points->rect)
|
||||||
parent (cfh/get-parent objects id)
|
frame (cfh/get-frame objects shape)
|
||||||
delta (if-not (:relative? options)
|
delta (get-relative-delta position bbox frame)
|
||||||
(get-delta position bbox)
|
|
||||||
(get-relative-delta position bbox parent))
|
|
||||||
modif-tree (dwm/create-modif-tree [id] (ctm/move-modifiers delta))]
|
modif-tree (dwm/create-modif-tree [id] (ctm/move-modifiers delta))]
|
||||||
(rx/of (dwm/apply-modifiers {:modifiers modif-tree
|
(rx/of (dwm/apply-modifiers {:modifiers modif-tree
|
||||||
:page-id page-id
|
:page-id page-id
|
||||||
|
|
|
@ -239,9 +239,8 @@
|
||||||
do-position-change
|
do-position-change
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps ids)
|
(mf/deps ids)
|
||||||
(fn [shape' frame' value attr]
|
(fn [shape' value attr]
|
||||||
(let [to (+ value (attr frame'))]
|
(st/emit! (udw/update-position (:id shape') {attr value}))))
|
||||||
(st/emit! (udw/update-position (:id shape') {attr to})))))
|
|
||||||
|
|
||||||
on-position-change
|
on-position-change
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
@ -249,7 +248,7 @@
|
||||||
(fn [value attr]
|
(fn [value attr]
|
||||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||||
(binding [cts/*wasm-sync* true]
|
(binding [cts/*wasm-sync* true]
|
||||||
(doall (map #(do-position-change %1 %2 value attr) shapes frames)))))
|
(doall (map #(do-position-change %1 value attr) shapes)))))
|
||||||
|
|
||||||
;; ROTATION
|
;; ROTATION
|
||||||
|
|
||||||
|
|
|
@ -290,12 +290,6 @@
|
||||||
{:ignore-touched true
|
{:ignore-touched true
|
||||||
:page-id page-id}))))))))
|
:page-id page-id}))))))))
|
||||||
|
|
||||||
(defn- immediate-flex-absolute-child? [objects id]
|
|
||||||
(let [shape (get objects id)]
|
|
||||||
(boolean
|
|
||||||
(and (:layout-item-absolute shape)
|
|
||||||
(ctsl/flex-layout-immediate-child? objects shape)))))
|
|
||||||
|
|
||||||
(defn update-shape-position
|
(defn update-shape-position
|
||||||
([value shape-ids attributes] (update-shape-position value shape-ids attributes nil))
|
([value shape-ids attributes] (update-shape-position value shape-ids attributes nil))
|
||||||
([value shape-ids attributes page-id]
|
([value shape-ids attributes page-id]
|
||||||
|
@ -303,21 +297,12 @@
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
(when (number? value)
|
(when (number? value)
|
||||||
(let [page-id' (or page-id (get state :current-page-id))
|
(let [page-id' (or page-id (get state :current-page-id))]
|
||||||
objects (dsh/lookup-page-objects state page-id')
|
|
||||||
{canvas-children-ids false
|
|
||||||
flex-children-ids true} (group-by #(immediate-flex-absolute-child? objects %) shape-ids)]
|
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(concat
|
(map #(dwt/update-position % (zipmap attributes (repeat value))
|
||||||
(map #(dwt/update-position % (zipmap attributes (repeat value))
|
{:ignore-touched true
|
||||||
{:ignore-touched true
|
:page-id page-id'})
|
||||||
:page-id page-id'})
|
shape-ids))))))))
|
||||||
canvas-children-ids)
|
|
||||||
(map #(dwt/update-position % (zipmap attributes (repeat value))
|
|
||||||
{:ignore-touched true
|
|
||||||
:page-id page-id'
|
|
||||||
:relative? true})
|
|
||||||
flex-children-ids)))))))))
|
|
||||||
|
|
||||||
|
|
||||||
(defn update-layout-sizing-limits
|
(defn update-layout-sizing-limits
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue