From 7a93a067707bcb8590059b96430b026926bdc923 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 27 Apr 2020 16:24:45 +0200 Subject: [PATCH] :bug: Fix text edition mode. --- .../uxbox/main/data/workspace/transforms.cljs | 21 +++++++++++++------ frontend/src/uxbox/util/geom/matrix.cljs | 6 ++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/frontend/src/uxbox/main/data/workspace/transforms.cljs b/frontend/src/uxbox/main/data/workspace/transforms.cljs index 6ecc3c3968..79346b6844 100644 --- a/frontend/src/uxbox/main/data/workspace/transforms.cljs +++ b/frontend/src/uxbox/main/data/workspace/transforms.cljs @@ -51,7 +51,7 @@ my (+ sy (/ height 2)) ex (+ sx width) ey (+ sy height) - + [x y] (case handler :right [sx my] :bottom [mx sy] @@ -92,7 +92,7 @@ ;; Resize origin point given the selected handler origin (-> (handler-resize-origin shape handler) (gsh/transform-shape-point shape shape-transform))] - + (rx/of (set-modifiers ids {:resize-vector scalev :resize-origin origin @@ -167,7 +167,8 @@ ;; -- MOVE -(defn start-move-selected [] +(defn start-move-selected + [] (ptk/reify ::start-move-selected ptk/WatchEvent (watch [_ state stream] @@ -175,15 +176,23 @@ stoper (rx/filter ms/mouse-up? stream) zero-point? #(= % (gpt/point 0 0)) initial (apply-zoom @ms/mouse-position) - position @ms/mouse-position] + position @ms/mouse-position + counter (volatile! 0)] (rx/concat (->> ms/mouse-position (rx/map apply-zoom) (rx/filter (complement zero-point?)) (rx/map #(gpt/subtract % initial)) - (rx/map #(set-modifiers selected {:displacement (gmt/translate-matrix %)})) + (rx/map gmt/translate-matrix) + (rx/filter #(not (gmt/base? %))) + (rx/map #(set-modifiers selected {:displacement %})) + (rx/tap #(vswap! counter inc)) (rx/take-until stoper)) - (rx/of (apply-modifiers selected))))))) + (->> (rx/create (fn [sink] (sink @counter))) + (rx/mapcat (fn [n] + (if (zero? n) + (rx/empty) + (rx/of (apply-modifiers selected))))))))))) (defn- get-displacement-with-grid "Retrieve the correct displacement delta point for the diff --git a/frontend/src/uxbox/util/geom/matrix.cljs b/frontend/src/uxbox/util/geom/matrix.cljs index 18bee57eef..d8b97010ea 100644 --- a/frontend/src/uxbox/util/geom/matrix.cljs +++ b/frontend/src/uxbox/util/geom/matrix.cljs @@ -52,6 +52,12 @@ ([a b c d e f] (Matrix. a b c d e f))) +(def base (matrix)) + +(defn base? + [v] + (= v base)) + (defn translate-matrix [{x :x y :y :as pt}] (assert (gpt/point? pt))