0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-01 01:21:21 -05:00

🐛 Fixed problem when create a shape with click

This commit is contained in:
alonso.torres 2020-09-17 14:28:43 +02:00 committed by Andrey Antukh
parent e860f9d62b
commit 558bcc07b2

View file

@ -80,6 +80,7 @@
(gpt/point v v)) (gpt/point v v))
scalev)] scalev)]
(-> shape (-> shape
(assoc ::click-draw? false)
(assoc-in [:modifiers :resize-vector] scalev) (assoc-in [:modifiers :resize-vector] scalev)
(assoc-in [:modifiers :resize-origin] (gpt/point x y)) (assoc-in [:modifiers :resize-origin] (gpt/point x y))
(assoc-in [:modifiers :resize-rotation] 0)))) (assoc-in [:modifiers :resize-rotation] 0))))
@ -112,7 +113,8 @@
(get-in [:workspace-drawing :object]) (get-in [:workspace-drawing :object])
(geom/setup {:x (:x initial) :y (:y initial) :width 1 :height 1}) (geom/setup {:x (:x initial) :y (:y initial) :width 1 :height 1})
(assoc :frame-id fid) (assoc :frame-id fid)
(assoc ::initialized? true))] (assoc ::initialized? true)
(assoc ::click-draw? true))]
(rx/concat (rx/concat
;; Add shape to drawing state ;; Add shape to drawing state
(rx/of #(assoc-in state [:workspace-drawing :object] shape)) (rx/of #(assoc-in state [:workspace-drawing :object] shape))
@ -123,6 +125,7 @@
#(update-in % [:workspace-drawing :object] assoc :x x :y y)))) #(update-in % [:workspace-drawing :object] assoc :x x :y y))))
(->> ms/mouse-position (->> ms/mouse-position
(rx/filter #(> (gpt/distance % initial) 2))
(rx/with-latest vector ms/mouse-position-ctrl) (rx/with-latest vector ms/mouse-position-ctrl)
(rx/switch-map (rx/switch-map
(fn [[point :as current]] (fn [[point :as current]]
@ -269,15 +272,23 @@
(rx/concat (rx/concat
(rx/of dw/clear-drawing) (rx/of dw/clear-drawing)
(when (::initialized? shape) (when (::initialized? shape)
(let [shape-min-width (case (:type shape) (let [shape-click-width (case (:type shape)
:text 20 :text 150
5) 20)
shape-min-height (case (:type shape) shape-click-height (case (:type shape)
:text 16 :text 40
5) 20)
shape (if (::click-draw? shape)
(-> shape
(assoc-in [:modifiers :resize-vector]
(gpt/point shape-click-width shape-click-height))
(assoc-in [:modifiers :resize-origin]
(gpt/point (:x shape) (:y shape))))
shape)
shape (-> shape shape (-> shape
geom/transform-shape geom/transform-shape
(dissoc ::initialized?)) ] (dissoc ::initialized?
::click-draw?))]
;; Add & select the created shape to the workspace ;; Add & select the created shape to the workspace
(rx/of dw/deselect-all (rx/of dw/deselect-all
(dw/add-shape shape))))))))) (dw/add-shape shape)))))))))