From 8d99bd723b8a01a14318cb3f84b9fe864979627d Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 30 Jan 2020 13:28:27 +0100 Subject: [PATCH] :bug: Fix rotation of path and curve shapes. --- frontend/src/uxbox/main/geom.cljs | 1 + frontend/src/uxbox/main/ui/shapes/path.cljs | 23 ++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/frontend/src/uxbox/main/geom.cljs b/frontend/src/uxbox/main/geom.cljs index 2d54482b8..0ed400498 100644 --- a/frontend/src/uxbox/main/geom.cljs +++ b/frontend/src/uxbox/main/geom.cljs @@ -575,6 +575,7 @@ xf-resolve-shapes (comp (map shape->rect-shape) (map resolve-modifier) + (map shape->rect-shape) (map resolve-rotation) (map shape->rect-shape))) diff --git a/frontend/src/uxbox/main/ui/shapes/path.cljs b/frontend/src/uxbox/main/ui/shapes/path.cljs index aa2dac266..70ab92544 100644 --- a/frontend/src/uxbox/main/ui/shapes/path.cljs +++ b/frontend/src/uxbox/main/ui/shapes/path.cljs @@ -62,23 +62,30 @@ (mf/defc path-shape [{:keys [shape background?] :as props}] (let [modifier-mtx (:modifier-mtx shape) + rotation (:rotation shape) + shape (cond (gmt/matrix? modifier-mtx) (geom/transform shape modifier-mtx) :else shape) - moving? (boolean modifier-mtx) + {:keys [id x y width height]} (geom/shape->rect-shape shape) + + transform (when (and rotation (pos? rotation)) + (str/format "rotate(%s %s %s)" + rotation + (+ x (/ width 2)) + (+ y (/ height 2)))) pdata (render-path shape) - props {:id (str (:id shape)) - :class (classnames :move-cursor moving?) - :d pdata} - - attrs (merge (attrs/extract-style-attrs shape) props)] + props (-> (attrs/extract-style-attrs shape) + (assoc :transform transform + :id (str "shape-" id) + :d pdata))] (if background? [:g [:path {:stroke "transparent" :fill "transparent" :stroke-width "20px" :d pdata}] - [:> :path (normalize-props attrs)]] - [:> :path (normalize-props attrs)]))) + [:& "path" props]] + [:& "path" props])))