diff --git a/frontend/src/app/main/data/workspace/transforms.cljs b/frontend/src/app/main/data/workspace/transforms.cljs index 06f3788c6..0c5effb80 100644 --- a/frontend/src/app/main/data/workspace/transforms.cljs +++ b/frontend/src/app/main/data/workspace/transforms.cljs @@ -859,6 +859,12 @@ (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 frame] (let [frame-bbox (-> frame :points grc/points->rect) relative-cpos (gpt/subtract (gpt/point (:x bbox) (:y bbox)) @@ -884,7 +890,9 @@ ;; FIXME: performance rect bbox (-> shape :points grc/points->rect) frame (cfh/get-frame objects shape) - delta (get-relative-delta position bbox frame) + delta (if (:absolute? options) + (get-delta position bbox) + (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 diff --git a/frontend/src/app/plugins/shape.cljs b/frontend/src/app/plugins/shape.cljs index 4f78b16b2..5b1fe0467 100644 --- a/frontend/src/app/plugins/shape.cljs +++ b/frontend/src/app/plugins/shape.cljs @@ -492,7 +492,9 @@ (u/display-not-valid :x "Plugin doesn't have 'content:write' permission") :else - (st/emit! (dw/update-position id {:x value})))))} + (st/emit! (dw/update-position id + {:x value} + {:absolute? true})))))} :y {:this true @@ -508,7 +510,9 @@ (u/display-not-valid :y "Plugin doesn't have 'content:write' permission") :else - (st/emit! (dw/update-position id {:y value})))))} + (st/emit! (dw/update-position id + {:y value} + {:absolute? true})))))} :parent {:this true @@ -542,7 +546,9 @@ parent-id (-> self u/proxy->shape :parent-id) parent (u/locate-shape (obj/get self "$file") (obj/get self "$page") parent-id) parent-x (:x parent)] - (st/emit! (dw/update-position id {:x (+ parent-x value)})))))} + (st/emit! (dw/update-position id + {:x (+ parent-x value)} + {:absolute? true})))))} :parentY {:this true @@ -567,7 +573,9 @@ parent-id (-> self u/proxy->shape :parent-id) parent (u/locate-shape (obj/get self "$file") (obj/get self "$page") parent-id) parent-y (:y parent)] - (st/emit! (dw/update-position id {:y (+ parent-y value)})))))} + (st/emit! (dw/update-position id + {:y (+ parent-y value)} + {:absolute? true})))))} :boardX {:this true @@ -592,7 +600,9 @@ frame-id (-> self u/proxy->shape :frame-id) frame (u/locate-shape (obj/get self "$file") (obj/get self "$page") frame-id) frame-x (:x frame)] - (st/emit! (dw/update-position id {:x (+ frame-x value)})))))} + (st/emit! (dw/update-position id + {:x (+ frame-x value)} + {:absolute? true})))))} :boardY {:this true @@ -617,7 +627,9 @@ frame-id (-> self u/proxy->shape :frame-id) frame (u/locate-shape (obj/get self "$file") (obj/get self "$page") frame-id) frame-y (:y frame)] - (st/emit! (dw/update-position id {:y (+ frame-y value)})))))} + (st/emit! (dw/update-position id + {:y (+ frame-y value)} + {:absolute? true})))))} :width {:this true