From de09217e30ceaaead99eb7347ec4e4bece0bffe9 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 27 Jan 2020 13:25:36 +0100 Subject: [PATCH] :bug: Fix rotation transformation on image shape. --- frontend/src/uxbox/main/ui/shapes/image.cljs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/frontend/src/uxbox/main/ui/shapes/image.cljs b/frontend/src/uxbox/main/ui/shapes/image.cljs index 926905c4f..fd61bbbea 100644 --- a/frontend/src/uxbox/main/ui/shapes/image.cljs +++ b/frontend/src/uxbox/main/ui/shapes/image.cljs @@ -8,13 +8,13 @@ (:require [lentes.core :as l] [rumext.alpha :as mf] + [cuerdas.core :as str] [uxbox.main.data.images :as udi] [uxbox.main.geom :as geom] [uxbox.main.refs :as refs] [uxbox.main.store :as st] [uxbox.main.ui.shapes.attrs :as attrs] [uxbox.main.ui.shapes.common :as common] - [uxbox.util.data :refer [classnames normalize-props]] [uxbox.util.geom.matrix :as gmt])) ;; --- Refs @@ -47,17 +47,25 @@ (mf/defc image-shape [{:keys [shape image] :as props}] - (let [{:keys [id x y width height modifier-mtx]} shape - moving? (boolean modifier-mtx) - transform (when (gmt/matrix? modifier-mtx) - (str modifier-mtx)) + (let [{:keys [id rotation modifier-mtx]} shape + + shape (cond + (gmt/matrix? modifier-mtx) (geom/transform shape modifier-mtx) + :else shape) + + {:keys [x y width height]} shape + + transform (when (and rotation (pos? rotation)) + (str/format "rotate(%s %s %s)" + rotation + (+ x (/ width 2)) + (+ y (/ height 2)))) props (-> (attrs/extract-style-attrs shape) (assoc :x x :y y :id (str "shape-" id) :preserveAspectRatio "none" - :className (classnames :move-cursor moving?) :xlinkHref (:url image) :transform transform :width width