🐛 Fix token dimension application for all relatively positioned shapes

This commit is contained in:
Andrey Fedorov 2025-03-07 10:48:20 +01:00 committed by Andrés Moya
parent 44ca01aa27
commit 5f3599eaa7
3 changed files with 10 additions and 34 deletions

View file

@ -859,12 +859,6 @@
(rx/of (reorder-selected-layout-child direction))
(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]
(let [parent-bbox (-> parent :points grc/points->rect)
relative-cpos (gpt/subtract (gpt/point (:x bbox) (:y bbox))
@ -888,10 +882,8 @@
shape (get objects id)
;; FIXME: performance rect
bbox (-> shape :points grc/points->rect)
parent (cfh/get-parent objects id)
delta (if-not (:relative? options)
(get-delta position bbox)
(get-relative-delta position bbox parent))
frame (cfh/get-frame objects shape)
delta (get-relative-delta position bbox frame)
modif-tree (dwm/create-modif-tree [id] (ctm/move-modifiers delta))]
(rx/of (dwm/apply-modifiers {:modifiers modif-tree
:page-id page-id

View file

@ -239,9 +239,8 @@
do-position-change
(mf/use-fn
(mf/deps ids)
(fn [shape' frame' value attr]
(let [to (+ value (attr frame'))]
(st/emit! (udw/update-position (:id shape') {attr to})))))
(fn [shape' value attr]
(st/emit! (udw/update-position (:id shape') {attr value}))))
on-position-change
(mf/use-fn
@ -249,7 +248,7 @@
(fn [value attr]
(st/emit! (udw/trigger-bounding-box-cloaking ids))
(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

View file

@ -290,12 +290,6 @@
{:ignore-touched true
: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
([value shape-ids attributes] (update-shape-position value shape-ids attributes nil))
([value shape-ids attributes page-id]
@ -303,21 +297,12 @@
ptk/WatchEvent
(watch [_ state _]
(when (number? value)
(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)]
(let [page-id' (or page-id (get state :current-page-id))]
(rx/concat
(concat
(map #(dwt/update-position % (zipmap attributes (repeat value))
{:ignore-touched true
:page-id page-id'})
canvas-children-ids)
(map #(dwt/update-position % (zipmap attributes (repeat value))
{:ignore-touched true
:page-id page-id'
:relative? true})
flex-children-ids)))))))))
(map #(dwt/update-position % (zipmap attributes (repeat value))
{:ignore-touched true
:page-id page-id'})
shape-ids))))))))
(defn update-layout-sizing-limits