0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-10 09:08:31 -05:00

🐛 Fix problem with selection rect

This commit is contained in:
alonso.torres 2022-02-08 12:11:56 +01:00
parent 979f61df99
commit 39b05f5f9f

View file

@ -9,6 +9,7 @@
[app.common.data :as d] [app.common.data :as d]
[app.common.geom.point :as gpt] [app.common.geom.point :as gpt]
[app.common.geom.shapes :as geom] [app.common.geom.shapes :as geom]
[app.common.math :as mth]
[app.common.pages :as cp] [app.common.pages :as cp]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.interactions :as cti] [app.common.spec.interactions :as cti]
@ -56,21 +57,27 @@
init-selrect init-selrect
{:type :rect {:type :rect
:x (:x @ms/mouse-position) :x1 (:x @ms/mouse-position)
:y (:y @ms/mouse-position) :y1 (:y @ms/mouse-position)
:width 0 :x2 (:x @ms/mouse-position)
:height 0} :y2 (:y @ms/mouse-position)}
calculate-selrect calculate-selrect
(fn [selrect [delta space?]] (fn [selrect [delta space?]]
(if space? (let [result
(-> selrect (cond-> selrect
(update :x + (:x delta)) :always
(update :y + (:y delta))) (-> (update :x2 + (:x delta))
(update :y2 + (:y delta)))
(-> selrect space?
(update :width + (:x delta)) (-> (update :x1 + (:x delta))
(update :height + (:y delta))))) (update :y1 + (:y delta))))]
(assoc result
:x (min (:x1 result) (:x2 result))
:y (min (:y1 result) (:y2 result))
:width (mth/abs (- (:x2 result) (:x1 result)))
:height (mth/abs (- (:y2 result) (:y1 result))))))
selrect-stream selrect-stream
(->> ms/mouse-position (->> ms/mouse-position